Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. function ListItem({item}) {
  2. return (...);
  3. }
  4. function mapStateToProps(state, ownProps) {
  5. // look up item from state using ownProps.id e.g. if `state` maps ids to objects
  6. const item = state[ownProps.id];
  7. return {
  8. item,
  9. };
  10. }
  11. const ConnectedListItem = connect(mapStateToProps)(ListItem);
  12.  
  13. function List({itemIds}) {
  14. return (
  15. <FlatList
  16. data={itemIds}
  17. renderItem={({item}) => <ConnectedListItem id={item} />}
  18. ...
  19. />
  20. }
  21.  
  22. // example: <List itemIds=[1, 2, 3] />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement