use-s-react
Version:
useS is a minimal yet powerful React hook for managing both local and global state — with zero boilerplate
14 lines (13 loc) • 387 B
JavaScript
export function normalizeUseSArgs(config) {
const isValidGlobalConfig = typeof config === "object" &&
config !== null &&
"value" in config &&
"key" in config;
const initialValue = isValidGlobalConfig
? config.value
: config;
const key = isValidGlobalConfig
? config.key
: undefined;
return { initialValue, key };
}