useCachedState
Hook which returns a stateful value, and a function to update it. It is similar to React's useState but the value will be kept between command runs.
Signature
function useCachedState<T>(
key: string,
initialState?: T,
config?: {
cacheNamespace?: string;
},
): [T, (newState: T | ((prevState: T) => T)) => void];Arguments
keyis the unique identifier of the state. This can be used to share the state across components and/or commands (hooks using the same key will share the same state, eg. updating one will update the others).
With a few options:
initialStateis the initial value of the state if there aren't any in the Cache yet.config.cacheNamespaceis a string that can be used to namespace the key.
Example
Last updated

