Skip to content

Passing props down to rows #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Rich-Harris opened this issue Apr 3, 2018 · 0 comments · Fixed by #8
Closed

Passing props down to rows #4

Rich-Harris opened this issue Apr 3, 2018 · 0 comments · Fixed by #8

Comments

@Rich-Harris
Copy link
Member

Currently, the row component can only access row, which means no information about the outside world — for example, we can't highlight some text that's being used to filter rows, because we can't pass down the filter text.

Maybe something like this:

<VirtualList items={{...}} component={{...}} props='{{ { foo, bar } }}' />

Then, it would be passed to the row like so:

<:Component {component} {{...props}} row={{item.data}} />

The props= is a little unfortunate, especially since it means having a clusterfuck of curly braces. This is one place where the React model wins, because you can do this:

const { items, component, ...props } = this.props;

return visible.map(item =>
  <Component {...props} row={item.data} />
);

In Svelte there isn't a great way to accomplish that. Even the {{...this}} proposal (sveltejs/svelte#1303) doesn't really help, though I suppose it'd be possible to do this:

<:Component {component} {{...(exclude(this, ['items', 'component'])}} row={{item.data}} />
This was referenced Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant