T
TanStack2y ago
genetic-orange

dynamically changing options

I noticed the setOptions method that the table instance returns in the docs. Am I able to use this method to dynamically change options? Or is controlling the options directly the best way. If I wanted to setup options directly like so:
const [tableOptions, setTableOptions] = useState({...})
const table = useReactTable(tableOptions)
const [tableOptions, setTableOptions] = useState({...})
const table = useReactTable(tableOptions)
I would need to pass setTableOptions as a meta to tableOptions and wasnt sure if this is the correct way to do this.
useEffect(() => {
setTableOptions((oldOptions) => {
return {
...oldOptions,
meta: {...oldOptions.meta, setTableOptions }
}
})
}, [])
useEffect(() => {
setTableOptions((oldOptions) => {
return {
...oldOptions,
meta: {...oldOptions.meta, setTableOptions }
}
})
}, [])
Whereas using setOptions seem to be easier to use, but I'm not sure if the table options need to be stable by passing in the initial options with useMemo
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?