Access filtered data in ReactTable
I have just found the answer by referencing this article
get refer of table like following:
<ReactTable ref={(r) => { this.selectTable = r; }} .../>
And in your function
const currentRecords = this.selectTable.getResolvedState().sortedData;
If you are using React 16.7-alpha+ with hooks you can do something like the following too.
import { useState, useRef } from 'react';const [pageSize, setPageSize] = useState(20);let reactTable = useRef(null);<ReactTable ref={(r) => (reactTable = r)} onFilteredChange={() => { setPageSize(reactTable.getResolvedState().sortedData.length); }}/>
React table can take a render prop as a child, and you can pick data off the table state that is passed to that render fn,
<ReactTable {...props}> {(state, makeTable, instance) => { // take data from state, resolvedData, or sortedData, if order matters (for export and similar) // you need to call makeTable to render the table return ( <> {makeTable()} {<p>{`Showing ${state.resolvedData.length} entries`}</p>} </> ); }}</ReactTable>