Reactabular provides three components: Table.Provider, Table.Header, and Table.Body. Table.Provider sets the data context. It may contain multiple Table.Header and Table.Body elements. You can control data per body while the provider maintains a shared column definition.
Table.Provider
Table.Provider is the core of Reactabular. It sets up a context and maps the column definition to its children components. The following example illustrates the basic idea.
It is possible to customize a header by passing child components to it. This way you can implement filtering per column for instance.
Here search.Columns injects an additional row for the filter controls. An alternative way to handle it would be to push the problem to the column definition.
Table.Body renders table rows within a Table.Provider context. It accepts either an array of objects or an array of arrays (see the Excel example). In the former case you should define a rowKey. This allows React to render in a more performant way.
Most often you'll define rowKey as a string. An alternative is to define it using a function like this: rowKey={({ rowData, rowIndex }) => rowData.nested.id}. This is useful if your key is nested or related to some other data. Another way to avoid this problem is to generate the field using reactabular-resolve and then point to that through a string.
It is possible to customize body behavior on a row level. onRow prop accepts function (row, { rowIndex, rowKey }) => ({...}) that allows you to set custom attributes per each row.
It's a good idea to define a possible row handler separately to avoid binding per each render. If you write the handler inline, it will bind each time render() is called and reduce performance slightly.
Customizing Table Footer
It is possible to inject a custom footer like this: