re: New Redux Hooks: A Before And After Comparison. Are They Better? VIEW POST


Nitpick: we have a useStore() hook that returns the store instance, rather than a useState() hook that returns the store state. (If you wanted a useState() hook, that'd just be const state = useSelector(state => state), but that'd be bad because your component would re-render on every state update.)

I agree that the testing question becomes somewhat more difficult - you're basically having to write "integration"-ish tests now to test the component in conjunction with the Redux store state it expects. The React team seems to be encouraging more integration-style testing in general, though.


Thanks for bringing that to my intention. I've fixed the error in the article.

Add that's a good point on testing. You can no longer test just the component by mocking out all of the redux parts, but that may be a feature more than a bug. I've been moving towards more integration-style testing in my work as well. Still, probably one of the bigger differences you'll face moving from connect to hooks.

Code of Conduct Report abuse