react-use-notifier
v0.4.1
Published
Notifier hooks for react, usefull to create state binding and watch changes preventing many rerenders
Downloads
46
Maintainers
Readme
Changelog
Link to versioned changelog for internal devs
useNotifier for React ⭐🚀
notifier definition
const counter = useNotifier(5);
now you can provide notifier in context
update notifier value by
counter.value = 7;
Consume value
consume with hook
this hook will subscribe component to changes
const value = useNotifierValue(counter);
watch function wrapper
you can wrap your render function with "watch" that subscribes to each notifier
return watch(() => <div children={counter.value}/>)
the following implementation does not subscribes to changes
return <div children={counter.value}/>
Watcher component wrapper
<Watcher>
{() => <div children={counter.value}/>}
</Watcher>
or
<Watcher
children={() => <div children={counter.value}/>}
/>