Hacker News new | ask | show | jobs
by nothrows 2751 days ago
I'm curious about the direction react redux will take with the new hook api. What will the react redux hooks will look like? Will that be something that lands soon in an alpha?
2 comments

Yeah, @tlrobinson linked our issue discussing it.

The big blocker for us shipping a `useRedux()` hook is that there's currently no way for a function component to bail out of re-rendering once it starts, and calling `useContext()` subscribes that function component to _any_ update of the context value. The React team has an issue tracking that (https://github.com/facebook/react/issues/14110 ), and as far as I know that's something they intend to include before 16.7 goes final.

Once that's available, we can look at implementing an official `useRedux()` hook, and ship it in a future release.

That same release would likely also rewrite the guts of `connect` to actually use hooks internally as well. I already threw together a proof-of-concept PR that does this (https://github.com/reduxjs/react-redux/pull/1065 ).