Skip to content

Bhoos/redux-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redux-hooks

react hooks for redux state / dispatch. replaces react-redux.

installation

yarn add redux-hooks

you must be using react v16.7.0-alpha

usage

add your store to the provider

import { Provider } from 'redux-hooks'

ReactDOM.render(
  <Provider store={store}>
    <App/>
  </Provider>
)

use the store hook as a replacement for mapStateToProps and useAction as a replacement for mapDispatchToProps

export default function App() {
  const teams = useStore(state => state.teams)

  useAction(dispatch => dispatch(fetchTeams()))

  return (
    <ul>
      {teams.map(t => <li>{t.name}</li>)}
    </ul>
  )
}

check out nhl-hooks for a real-world example.


init'd with golf

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published