Skip to content

thetinydots/use-shared-state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@tinyd/usesharedstate

Shared States across multiple components.

Available hooks 🪝

  1. useSharedState
  2. useSharedStateValue
  3. useSharedStateChange

Available functions ⚙️

  1. getOrSetSharedValue
  2. setSharedValue

Usage

  1. useSharedState ( Hook 🪝 )
const [value, setValue] = useSharedState<string>(
  "key",
  "initialValue"
); //second arg is optional
  1. useSharedStateValue ( Hook 🪝 )
const value = useSharedStateValue<string>(
  "key",
  "initialValue"
); //second arg is optional
  1. useSharedStateChange ( Hook 🪝 )
const setValue =
  useSharedStateChange<string>("key");
  1. getOrSetSharedValue ( Function ⚙️ )
const value = getOrSetSharedValue<string>(
  "key",
  "initialValue"
); //second arg is optional
  1. setSharedValue ( Function ⚙️ )
const value = setSharedValue<string>(
  "key",
  "value"
);

Releases

No releases published

Packages

No packages published