React Hooks implementation for Redux that does not suffer from the tearing / "zombie child component" problems. Read more.
It also implements performance optimizations eg. does not render when the map state function does not produce new value and allows advanced optimizations with memoizing and dependency arrays.
Written in TypeScript so types are baked in and always up to date.
npm install @epeli/redux-hooks
Your components must be wrapped with the
;ReactDOM.renderHooksProvider store=Counter //HooksProvider,document.getElementById"app",;
Custom provider is required for now because the official react-redux bindings do not use subscriptions and it's impossible to implement Redux hooks without efficiently. Read more about it here.
📚 Available hooks
useMapState()Renders when returned value differ using
useSelect()Renders when returned value differ using shallow equal check
useActionCreators()Bind object of action creators to dispatch
useDispatch()Returns the plain dispatch-function
useMapState()but does not subscribe to the store eg. is executed only when the component renders.
Please read the optimizations docs for details when to use these.
You can use
createHooks() factory to create custom typed version of the hooks
🤔 Why yet another Redux Hooks implementation?
All the others I checked had the zombie child bug, poor performance or were missing TypeScript types.
facebookincubator/redux-react-hook one has the zombie bug which is stated in their FAQ. This one guarantees data flow top down like the official react-redux one does.
This also an experiment for the future of the react-redux: