would it be possible to expose a "value" prop on DropdownTreeSelect and get rid of the checked bool in TreeNode? #546
Replies: 4 comments
-
It does that already. The 2nd arg on |
Beta Was this translation helpful? Give feedback.
-
I guess my question is more so: it seems like every time i would need to interact with this component from a higher order component (as a controlled component) I would need to implement these helper functions Edit0: correct me if I am misinformed I am not trying to be critical I love the library! |
Beta Was this translation helpful? Give feedback.
-
@bturner1273 no worries. Feedback like yours is what makes a library better so I'm all for it. Managing state via HoC is a bit of kludge at the moment but a few things you mentioned, I wanted to clarify.
You can already do this by passing
You can use the object path HoC approach to avoid the tree traversal and instead access each node directly. You wouldn't have to do this if the above HoC is what you're really after. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
when I need to interact with this component from a higher order component keeping track of its state I end up needing to write/use code to deepClone the tree list from my state, then traverse it and find the value and set checked to true and all other TreeNode::checked to false.
i.e.
Could this logic be moved to the library in such a way that all I need to do is set the value(s) (mine is a radioSelect so N/A) to be selected and react-dropdown-tree-select can do this for me? I feel like the onChange could just pass a list of nodes and a bool saying whether it was a select or unselect, then user can do the rest of the tracking super easily by giving their list to the values prop of ReactDropdownTreeSelect
Edit: for deep cloning I used lodash.cloneDeep ALSO I am using this.state.parentIdDropdownData for ReactDropdownTreeSelectProps::data
Beta Was this translation helpful? Give feedback.
All reactions