I have tried to mock this up by saving the state in sessionStorage, and setting a timeout function to cause a delay (representing the time of communication with the database) before returning the state data.
**Current behavior**
Using custom solution described above, the table's state does not update.
**Expected behavior**
Table's state updates after customRestoreState returns state.
**Minimal reproduction of the problem with instructions**
Code: Select all
const getState = () => {
return new Promise ((resolve, reject) => {
setTimeout(() => {
resolve(JSON.parse(window.sessionStorage.getItem('dt-state-demo-custom')))
}, 3000)
})
}
const onCustomRestoreState = async () => {
const result = await getState();
return result;
}
return (
<div>
<Toast ref={toast}></Toast>
<div className="card">
<DataTable value={products} reorderableColumns onRowReorder={onRowReorder} onColReorder={onColReorder}
stateStorage="custom" customSaveState={onCustomSaveState} customRestoreState={onCustomRestoreState}>
<Column rowReorder style={{ width: '3em' }} />
{dynamicColumns}
</DataTable>
</div>
</div>
);