Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ListItem({item}) {
- return (...);
- }
- function mapStateToProps(state, ownProps) {
- // look up item from state using ownProps.id e.g. if `state` maps ids to objects
- const item = state[ownProps.id];
- return {
- item,
- };
- }
- const ConnectedListItem = connect(mapStateToProps)(ListItem);
- function List({itemIds}) {
- return (
- <FlatList
- data={itemIds}
- renderItem={({item}) => <ConnectedListItem id={item} />}
- ...
- />
- }
- // example: <List itemIds=[1, 2, 3] />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement