Skip to content

v7.1.0-alpha.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@markerikson markerikson released this 22 Apr 19:42
· 778 commits to master since this release

React hooks are cool. All the cool kids are adding hooks to their libraries. We wanna be cool too.

That's why React Redux now includes a set of hooks you can use as an alternative to connect()!

npm i react-redux@next
yarn add react-redux@next

This alpha release includes the following hooks:

  • useSelector(): extracts values from the Redux store state and subscribes to the store (similar to mapState)
  • useActions(): binds action creators so that they dispatch actions when called (similar to mapDispatch)
  • useRedux(): both extracts values and binds action creators (similar to connect())
  • useDispatch(): returns the store dispatch method
  • useStore(): returns the Redux store instance

For more details, please see the "Hooks" API reference page under the "next" version section of the React Redux docs. In addition, issue #1179: Discussion: Potential hooks API design contains the history of how these APIs were designed.

Please try these hooks out in your own apps, and give us feedback on how well they work!

We've opened up issue #1252 as a thread for feedback and discussion of the alpha.

Note: The hook APIs listed in this page are still experimental and in alpha! Try them out, but be aware that they may be changed before a final release, including potential renaming or removal.

Changes

Contributors

Thanks to:

  • @MrWolfZ for creating a proof-of-concept library for these hooks, turning that library into the core implementation PR, and helping work through a ton of edge cases and issues
  • everyone who built an unofficial Redux hooks library, particularly @ianobermiller and @epeli
  • everyone who helped brainstorm and refine ideas in #1063 and #1179