A way to trigger onFetchData in ReactTable
You can keep a reference to the table in the parent component:
render(
...
<ReactTable ref={(refReactTable) => {this.refReactTable = refReactTable;}}... />
...
and then fire the update from the parent like so:
this.refReactTable.fireFetchData()
Just if somebody is still looking for a way to do this, I was able to do it using hooks. You need a reference to the ReactTable
component and then call .fireFetchData()
to refetch the server data:
const Table = ({ columns, ...props }) => {
const [data, setData] = useState([]);
const [loading, setLoading] = useState(true);
const reactTable = useRef();
useEffect(() => {
reactTable.current && reactTable.current.fireFetchData();
}, [/* your variable(s) here*/]);
return (
<ReactTable
ref={reactTable}
data={data}
loading={loading}
columns={columns}
manual
onFetchData={(state, instance) => {
setLoading(true);
// ... fetchData
setData(data);
setLoading(false);
}}
{...props}
/>
);
};