Skip to content

Passing props down to rows #4

@Rich-Harris

Description

@Rich-Harris

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}} />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions