@tinyd/usesharedstate
v1.0.6
Published
Shared State hook
Downloads
5
Maintainers
Readme
@tinyd/usesharedstate
Shared States across multiple components.
Available hooks 🪝
- useSharedState
- useSharedStateValue
- useSharedStateChange
Available functions ⚙️
- getOrSetSharedValue
- setSharedValue
Usage
- useSharedState ( Hook 🪝 )
const [value, setValue] = useSharedState<string>(
"key",
"initialValue"
); //second arg is optional
- useSharedStateValue ( Hook 🪝 )
const value = useSharedStateValue<string>(
"key",
"initialValue"
); //second arg is optional
- useSharedStateChange ( Hook 🪝 )
const setValue =
useSharedStateChange<string>("key");
- getOrSetSharedValue ( Function ⚙️ )
const value = getOrSetSharedValue<string>(
"key",
"initialValue"
); //second arg is optional
- setSharedValue ( Function ⚙️ )
const value = setSharedValue<string>(
"key",
"value"
);