Last active
April 28, 2019 07:41
-
-
Save 3nvi/a77e907331db7d9f5c7e6bdee15289d6 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}>Update title</div>; | |
| export default connect(null, { updateTitle: updateTitleAction })(Component) | |
| // With Redux hooks! | |
| import React from 'react'; | |
| import { updateTitleAction } from './actions'; | |
| import { useActions } from 'react-redux'; | |
| const Component = props => { | |
| const updateTitle = useActions(updateTitleAction); | |
| return <button onClick={updateTitle}>Update title</div>; | |
| } |
First, thanks for the great write up!
Second, should line 20 be:
-const updateTitle = useActions(updateTitleAction);
+const updateTitle = useActions(updateTitle);
Author
Yup you both are right guys!
So sorry about that, 1 copy-paste mistake snowballed the whole thing. Thanks for spotting that out and for the kind words.
Have a nice day :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems the variable in the "With Redux hooks!" should not have
props.