redux-hooks
v0.1.5
Published
react hooks for redux
Downloads
224
Readme
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