How to get the initial selected nodes #548
Unanswered
RamsayRomero
asked this question in
Q&A
Replies: 1 comment
-
Well, you're setting the data in the first place - you can traverse through the tree and pick the "selected" values and assign to wherever you want to. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It seems like the only way to have access to the selectedNodes is through the second argument of the onChange function. However, I would like to have access to the initial value of the selectedNodes before onChange gets called. I'm getting the tree data from the backend and it comes with the initial values having "checked" set to true. I'm also integrating this component with react-hook-form's Controller component, which gets access to the values controlled components based on their "value" and "onChange" props. Since this component has no "value" prop, there is no way for react-hook-form to be aware of the initial value, so if I were to submit the form without changing the tree, the value would be undefined. Any thoughts on a way to get the initial selectedNode? Also why can't this component have a "value" prop? I've seen people ask this in other issues and the answer given is that the value is the second argument to onChange. However that doesn't work in this situation.
Beta Was this translation helpful? Give feedback.
All reactions