You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`hAlign`|`TextAlign`|Horizontal align of the cell|
39
39
|`vAlign`|`VerticalAlign`|Vertical align of the cell|
40
40
41
+
## Recipes
42
+
43
+
### How do I stop my table state from automatically resetting when my data changes?
44
+
45
+
46
+
By default, the `AnalyticalTable` will reset the sorters, filters, grouping, selected rows, etc. when the table data changes.
47
+
In case you want to keep the current state of the Table, you can disable this behavior by using the `reactTableOptions` prop:
48
+
```jsx
49
+
const [data, setData] =React.useState([])
50
+
constskipPageResetRef=React.useRef()
51
+
52
+
constupdateData=newData=> {
53
+
// When data gets updated with this function, set a flag
54
+
// to disable all of the auto resetting
55
+
skipPageResetRef.current=true
56
+
57
+
setData(newData)
58
+
}
59
+
60
+
React.useEffect(() => {
61
+
// After the table has updated, always remove the flag
62
+
skipPageResetRef.current=false
63
+
})
64
+
<AnalyticalTable
65
+
columns={columns}
66
+
data={data}
67
+
reactTableOptions={{
68
+
// ... any other options you want to set
69
+
autoResetExpanded:!skipPageResetRef.current,
70
+
autoResetGroupBy:!skipPageResetRef.current,
71
+
autoResetSelectedRows:!skipPageResetRef.current,
72
+
autoResetSortBy:!skipPageResetRef.current,
73
+
autoResetFilters:!skipPageResetRef.current,
74
+
}}
75
+
/>
76
+
```
77
+
78
+
For more details on this behavior you can double check the [react-table docs](https://github.com/tannerlinsley/react-table/blob/master/docs/faq.md#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes).
0 commit comments