Skip to content

Instantly share code, notes, and snippets.

@jks8787 jks8787/StuffList.js Secret
Last active Feb 11, 2018

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Feb 11, 2018

typo: suffList

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.