Closed dy closed 4 years ago
At core, there's useValue
with varying effects.
useLocalStorage
= useValue
+ init/persist to local storage
useStore
= useValue
with customizable persistency and initialization
useChannel
= useValue
with broadcasting value between channels
useGlobalCache
= useValue
with persistency/read from globals
useFormField
= useValue
with (optional) binding value to input: init from input, observe input, write to input;
Done. v2.0 contains only essential hooks.
Criticism
useProperty
is useless practice - instead of observing some external object, which is error-prone, better create and manage ownuseStore
.useLocalStorage
,useSessionStorage
,useCookie
- just particularities ofuseStore
.useGlobalCache
- useless.useCookie
- does not observe cookies changes.useAttribute
- doubtful, props/useElement
give better ground here.useElement
- false, it does not create selector observer.useSyncEffect
- likely unneeded.In result, stable hooks are:
useStore
as global named extension ofuseState
useAction
as global named extension ofuseCallback
useQueryParam
(particularity of useStore, but can be useful for UI)useFormField
(in fact - controller of state/actions)useElement
(or rather derivatives likeuseMeta
,useTitle
etc)