-
-
Save jks8787/02916a661cd9904ce13fca65da1a4046 to your computer and use it in GitHub Desktop.
stuffList connected component -- Medium Article gist
This file contains 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 {connect} from 'react-redux'; | |
import {bindActionCreators} from 'redux'; | |
import * as stuffActions from '../../actions/stuffActions'; | |
import PropTypes from 'prop-types'; | |
import React from 'react'; | |
class suffList extends React.Component { | |
renderData() { | |
return <div>{this.props.stuffs}</div>; | |
} | |
render() { | |
return ( | |
<div className=""> | |
{this.props.stuffs.length > 0 ? | |
this.renderData() | |
: | |
<div className=""> | |
No Data | |
</div> | |
} | |
</div> | |
); | |
} | |
} | |
suffList.propTypes = { | |
stuffActions: PropTypes.object, | |
stuffs: PropTypes.array | |
}; | |
function mapStateToProps(state) { | |
return { | |
stuffs: state.stuffs | |
}; | |
} | |
function mapDispatchToProps(dispatch) { | |
return { | |
stuffActions: bindActionCreators(stuffActions, dispatch) | |
}; | |
} | |
export default connect( | |
mapStateToProps, | |
mapDispatchToProps | |
)(suffList); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
typo:
suffList