Skip to content

Filter persistence on page reload or leave and return... #152

Answered by KevinVandy
kscottthomas asked this question in Q&A
Discussion options

You must be logged in to vote

From your original question, it sounds like you are able to successfully persist? I'm not sure of your exact question. Sounds like you are on the write path to managing the columnFilters state yourself.

If you follow this basic structure, it should work fine.

const [columnFilters, setColumnFilters] = useState([])

useEffect(() => {
  //read from localstorage
}, []}

useEffect(() => {
  //write to localstorage
}, [columnFilters]}

return (
  <MaterialReactTable
    columns={columns}
    data={data}
    onColumnFiltersChange={setColumnFilters}
    state={{ columnFilters }}
  />
)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kscottthomas
Comment options

Answer selected by KevinVandy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants