You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A select (combobox) component updates the DeniReactTreeView by setting it's root.
On each select, the root becomes the item selected, and we map the children of our model object into the necessary json required by the library.
This all works well on:
nothing selected in combobox => select something in combobox
combobox value set => select nothing in combobox
This makes the DeniReactTreeView refresh correctly.
However, when passing different set of items to the DeniReactTreeView, and the DeniReactTreeView state already has the rootItem.children set, the behavior is that the DeniReactTreeView is not refreshed although it's state is correct.
I traced the problem to lifecycle method componentDidUpdate where after setting the new props.items into the state, it's not refreshed immediately. Or the render does not take into account that the component's root items have changed.
Simple this.forceUpdate() did the trick but I think it may not be the best approach.
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
if (prevProps.items !== this.props.items) {
this.state.rootItem.children = this.props.items;
**this.forceUpdate();**
//treeviewHelper.loadData.call(this, this.props.items);
}
}
It seems that the component was never meant to change it's root a lot.
The text was updated successfully, but these errors were encountered:
Hi Deni,
We have a use case like so:
A select (combobox) component updates the
DeniReactTreeView
by setting it's root.On each select, the root becomes the item selected, and we map the children of our model object into the necessary json required by the library.
This all works well on:
This makes the
DeniReactTreeView
refresh correctly.However, when passing different set of items to the
DeniReactTreeView
, and theDeniReactTreeView
state already has therootItem.children set
, the behavior is that theDeniReactTreeView
is not refreshed although it's state is correct.I traced the problem to lifecycle method
componentDidUpdate
where after setting the newprops.items
into the state, it's not refreshed immediately. Or the render does not take into account that the component's rootitems
have changed.Simple
this.forceUpdate()
did the trick but I think it may not be the best approach.It seems that the component was never meant to change it's root a lot.
The text was updated successfully, but these errors were encountered: