Created
November 21, 2017 22:57
-
-
Save JiDai/a88054f0bc7c58ec279579ec1a98ca46 to your computer and use it in GitHub Desktop.
Redux container (JetBrains)
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, { Component } from 'react'; | |
| import { connect } from 'react-redux'; | |
| import PropTypes from 'prop-types'; | |
| /** | |
| * Select props from Redux state. | |
| * @param {Object} state Current state | |
| */ | |
| const mapStateToProps = state => ({ | |
| stateProp: state.stateProp, | |
| }); | |
| /** | |
| * Provide dispatch functions in props. | |
| * @param {Function} dispatch Redux dispatch function | |
| */ | |
| const mapDispatchToProps = dispatch => ({ | |
| stateAction: () => dispatch({ type: 'action' }), | |
| }); | |
| /** | |
| * ${NAME} Component. | |
| */ | |
| export class ${NAME}Component extends Component { | |
| /** | |
| * Creates an instance of ${NAME}Component. | |
| * @param {Object} props Component props | |
| */ | |
| constructor(props) { | |
| super(props); | |
| } | |
| /** | |
| * React lifecycle. | |
| */ | |
| render() { | |
| return ( | |
| ); | |
| } | |
| } | |
| ${NAME}Component.propTypes = { | |
| stateProp: PropTypes.string, | |
| stateAction: PropTypes.func, | |
| }; | |
| /** | |
| * ${NAME}Component connected. | |
| */ | |
| export default connect(mapStateToProps, mapDispatchToProps)(${NAME}Component); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment