Issue with setState #485
SchattenOpa
started this conversation in
General
Replies: 1 comment 5 replies
-
You already have the whole
You're doing a |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all,
I've seen other contributions and the "prevent-re-render"-solution given to previous issues.
However I don't think it works in my case so I'm opening a new issue here.
My problem is similar, when I call "setState" in the "onChange"-function my tree is collapsed and reset (for root-items they are still shown as "checked" though).
I don't create the data in my parent class for project-specific reasons, I retrieve it via a REST-Service and create my data-object in the "componentDidMount"-function in the child-component where the tree is located.
(For simplicity-reasons I use the default-data in my example)
Creating the tree works great, as does navigating and selecting.
However as soon as I add the setState-function (which I need for saving the selection in the parent component for further use) I run into the described issue.
I can't do the comparison from the shouldComponentUpdate since I don't have anything to compare.
So I think I either would have to search my tree for the selected value and change its "checked"-value or update the whole tree in the state to the current (I assume this would also be necessary to keep it expanded?)
Is there any way to get the whole "data"-prop from the tree just like I get the currentNode? Or any other way to solve the issue?
I've created an example HERE, it's simplified but the behavior is the same like in my own project.
Beta Was this translation helpful? Give feedback.
All reactions