Filtered table in React.js I am doing a filtered table in react, and I came up with the following code:

import React from 'react';
import { render } from 'react-dom';
import RowFilter from './RowFilter';
import List from './List';
import movieList from './movielist.json';

const data = movieList;
const App = () =&gt; (
  &lt;RowFilter data={data}&gt;
    &lt;List/&gt;
  &lt;/RowFilter&gt;
);

render(&lt;App /&gt;, document.getElementById('root'));


The implementation details are not that important since this is only a rough example, but the general idea is the following:

List normally expects a data array property so that it knows what to render

RowFilter has an input element and keeps track of a list of data. When the value changes, it updates the list of data.

RowFilter also sets the data property for it's child, whatever that child is

The result code works as expected, but I'm wondering about whether this is hard to read or considered a bad practice in general.

Running example
Yeah it's hard to read and only by looking at the source for RowFilter can you understand that it's injecting props into the child component that is given to it. Instead of passing it in as a child, you should pass it in a component prop.

&lt;RowFilter data={data} component={List} /&gt;


Then in RowFilter.js, the render simply looks like this. Note the component prop gets renamed to uppercase.

&lt;Component data={this.state.filteredData} /&gt;


Here's an updated example on codesandbox