Skip to content

Instantly share code, notes, and snippets.

@oshikryu
Last active December 6, 2019 19:30
Show Gist options
  • Select an option

  • Save oshikryu/0b0c1fa98b8f358fef2ee70d1da26ee7 to your computer and use it in GitHub Desktop.

Select an option

Save oshikryu/0b0c1fa98b8f358fef2ee70d1da26ee7 to your computer and use it in GitHub Desktop.
Updated component-redux
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