useStateGlobal()
An useStateGlobal()
represents main store in State-jet. It enables storing global data across React components without using a store.
function useStateGlobal<T>(
key: string,
initialValue?: T,
options?: { middleware?: Middleware<T>[], persist?: boolean, encrypt?: boolean }
)
-
key
- A unique string used to identify the store. -
initialValue
- can store any data types (string, array, object) -
options
- An optional parameter which supports multiple optionsmiddleware
- which is used to add middleware support for state jet. Refer (Middlewares)persist
- if persist is true, the store data will be stored in localStorage. Refer (Persistence)encrypt
- supports encryption/decryption. Refer (Encryption)
It returns the following properties: