Skip to content

Instantly share code, notes, and snippets.

@jks8787
Last active February 11, 2018 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jks8787/02916a661cd9904ce13fca65da1a4046 to your computer and use it in GitHub Desktop.
Save jks8787/02916a661cd9904ce13fca65da1a4046 to your computer and use it in GitHub Desktop.
stuffList connected component -- Medium Article gist
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);
@vance
Copy link

vance commented Feb 11, 2018

typo: suffList

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment