0.1.5 • Published 6 years ago

redux-hooks v0.1.5

Weekly downloads
15
License
MIT
Repository
github
Last release
6 years ago

redux-hooks

just react hooks for redux state / dispatch.

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

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago