After upgrading the Bryntum Grid React version from 4.1.1 to 4.1.6, I'm getting this error:
Uncaught TypeError: Cannot add property parentId, object is not extensible
at eval (grid.umd.js?0469:17021)
at _loop (grid.umd.js?0469:39771)
at Function.preWalkWithParent (grid.umd.js?0469:39785)
at Store.syncTreeDataset (grid.umd.js?0469:16998)
at Store.syncDataset (grid.umd.js?0469:16838)
at Store.setStoreData (grid.umd.js?0469:9419)
at Store.set (grid.umd.js?0469:9323)
at Grid.set (grid.umd.js?0469:124420)
at eval (WrapperHelper.js?b7f3:599)
at Array.forEach (<anonymous>)
This is where it is failing:
Can someone please tell me why this is happening? And is there any quick workaround for this?
We could not reproduce this issue. To assist you with your question, please provide more details including a runnable test case (as described in our support guidelines).
To get the fastest possible support, provide a simple test case based on our standard examples.
I will try to provide some more details and a test case. So, the data that I am working with is a Mobx State Tree array with frozen objects (https://mobx-state-tree.js.org/API/#frozen).
I checked if the individual items in that MST array are frozen with Object.isFrozen() and it returned true.
The interesting thing here is that the grid worked fine in version 4.1.1. In version 4.1.6 though, it suddenly throws errors if the array has frozen objects. Nothing has changed with my dataset. The grid just behaves differently when handling it.
My suspicion here is that maybe in the older version, the grid instance cloned the array before adding a parentId to it before, thus removing the problem. My quick workaround for now is to simply make a deep clone of the array before rendering the grid, but I'm still curious to know why this suddenly doesn't work anymore.
Last edited by Yamo1993 on Wed Jun 30, 2021 9:51 am, edited 4 times in total.
The showcase is already runnable. But it uses the mobx-state-tree and mobx-react packages. You should be able to test the grid with external packages too, not just drop it in an example sandbox, unless your sandbox is clever enough to install needed packages.
The data is provided in the code already. The data has a tree structure.
I changed the import to the provided wrapper, the behavior is still the same.
I don't believe we ever intended to support loading frozen data objects, looks like your MST is freezing the objects you pass in to our data stores, correct? Any chance you can opt out of this?