Skip to content
This repository has been archived by the owner on Sep 9, 2019. It is now read-only.

Blessed Lists support? #16

Open
blainekasten opened this issue May 23, 2016 · 2 comments
Open

Blessed Lists support? #16

blainekasten opened this issue May 23, 2016 · 2 comments

Comments

@blainekasten
Copy link
Owner

This is the biggest limitation i've found thus far:

Lists.

Due to implementation things, it's hard for a ListItem component to bind to it's index in the store. So they can't ever be wrapped. Is that actually a problem? Is it fine if the List itself is wrapped and just passes props the normal way? The hard part there is that the ListItem can't update state without passing actions created in the List.

Here is the only way to create a list right now:

function List({items, actions}) {
  return (
    <div>
      {items.map(
        (item, i) => <ListItem {...item} updateItem={actions.updateItem.bind(null, i)} />
      }
    </div>
  );
}

wrap(List, {
  mapStateToProps() {...},
  actions: { updateItem() {...} },
});

function ListItem({details, updateItem}) {
  return (
   <div onClick={updateItem}>{details}</div>
  );
}

This is how I dream we could make it:

function List({items, actions}) {
  return (
    <div>
      {items.map(
        (item, i) => <ListItem {...item} index={i} />
      }
    </div>
  );
}

wrap(List, {
  mapStateToProps() {
    return { items: 'items' };
  }
});

function ListItem({details, updateItem}) {
  return (
   <div onClick={updateItem}>{details}</div>
  );
}

wrap(List, {
  mapStateToProps(index) {
    return {
      details: `items[${index}].details`,
    };
  },
  actions: { updateItem() {...} },
});
@blainekasten
Copy link
Owner Author

Looking for feedback on this.

@blainekasten blainekasten changed the title Biggest limitation thus far Blessed Lists support? Aug 9, 2016
@TheLarkInn
Copy link
Contributor

CC @gaearon

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants