Tamir Gefen
Tamir Gefen

Reputation: 29

using material-table with redux state

I'm trying to use material-table while my data is stored in a redux global state.

It causes issues because I know @reduxjs/toolkit uses immer to make the state objects immutable (correct me if I'm wrong).

I saw one solution indicating its possilbe to use:

import { setAutoFreeze } from 'immer'; setAutoFreeze(false);

To cancel the auto freeze.

My question is this - doing so comes with risk? if the material-table needs to changes my data, it actually changes my global state which is bad behavior I assume?

Is it a valid solution or is it safer to look for a different data table lib?

Upvotes: 0

Views: 485

Answers (1)

phry
phry

Reputation: 44086

Immer aside, this will also cause problems with redux itself. And a lot of other libraries like apollo. See this issue: https://github.com/mbrn/material-table/issues/1371

At the moment you probably either have to do the hacks referenced in that ticket (and hope nothing breaks), wait for the rewrite or look for another table library. The last option is probably the best.

Upvotes: 2

Related Questions