Last active
December 6, 2019 19:30
-
-
Save oshikryu/0b0c1fa98b8f358fef2ee70d1da26ee7 to your computer and use it in GitHub Desktop.
Updated component-redux
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
| import React from 'react'; | |
| import { bindActionCreators } from 'redux'; | |
| import { connect } from 'react-redux'; | |
| import { actions as pollActions} from './actions'; | |
| export class MyComponent extends React.Component { | |
| componentDidMount() { | |
| const { actions } = this.props; | |
| actions.watchPollEndpoint(); | |
| } | |
| render() { | |
| const { items } = this.props; | |
| return ( | |
| <div> | |
| {items.map((obj) => obj} | |
| </div> | |
| ); | |
| } | |
| } | |
| const mapStateToProps = (state) => { | |
| return ({ | |
| ...state, | |
| }); | |
| }; | |
| const mapDispatchToProps = (dispatch) => ({ | |
| actions: bindActionCreators({ | |
| ...pollActions, | |
| }, dispatch), | |
| }); | |
| export default connect( | |
| mapStateToProps, | |
| mapDispatchToProps | |
| )(MyComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment