Open machour opened 6 years ago
@machour, Object.assign() only makes a shallow copy, while the component is intended to work with arbitrary nested objects.
Indeed @mindvr, plus we need data to be an array. [...data] would also make a shallow copy..
Any idea how to get the best of both worlds?
Correct by @mindvr
The only way is react-bootstrap-table
need to leverage on lodash or underscore, these lib seems like provide some deep copy functionality.
I will think it more about this issue, thanks
Hi and thank you for this amazing library!
I came across a little issue when using data constructed using
denormalize()
from the normalizr library.Considering the following data structure:
If "user" works at "company" (both Contact instances), then the structure output from
denormalize
will look like this:It have a circular reference, which is the behavior documented by Normalizr.
The problem is, that in react-bootstrap-table, right here, the following code is used, probably to clone the data array:
which causes the following error:
Is cloning the
data
variable the only thing that JSON.parse(JSON.stringify()) is trying to achieve? If so, maybe usingObject.assign({}, data}
could be better performance wise (and would make my error go away).Happy to submit a PR if this is accepted!