Last active
April 28, 2019 07:42
-
-
Save 3nvi/724372429e45576a4c51cd1df18d5893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Previously | |
| import React from 'react'; | |
| import { updateTitleAction } from './actions'; | |
| import { connect } from 'react-redux'; | |
| const Component = props => <button onClick={props.updateTitle}>{props.content}</div>; | |
| export default connect(state => state.content, { updateTitle: updateTitleAction })(Component) | |
| // With Redux hooks! (you could have also returned an object both as the 1st or the 2nd argument of `useRedux`) | |
| import React from 'react'; | |
| import { updateTitleAction } from './actions'; | |
| import { useRedux } from 'react-redux'; | |
| const Component = props => { | |
| const [content, updateTitle] = useRedux(state => state.content, updateTitleAction); | |
| return <button onClick={updateTitle}>{content}</div>; | |
| } |
Author
Yup, you are right!
Sorry about that and thanks for pointing that out :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems the variables in the "With Redux hooks!" should have not
props.