Weird react behaviour
I am rendering a element for every item inside of Root's children array, in that element i have a state to open or close the item (if its a dir). When someone opens a directory , i render a Nested Component that uses react query to fetch the contents of that directory and render them, and the nested component again renders the item (recursion goes on). This works fine in itself but when i have a zustand store that stores the current file and directory opened, the tree behaves in a very weird way.. the folders wont open even after multiple clicks and will randomly open on another click.
It seems like updating states is fine but when the component is re rendering coz of the state change, then its causing issues
https://pastebin.com/eJvbiirr
Pastebin
type ChildrenProps = { node: Node;};export function Children({ nod...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
2 Replies
You're randomly generating a new key prop for every node on every re-render on line 92. I don't know for sure whether that's causing the issues you're seeing, but it seems like it might, and you should probably fix it either way.
omg this actually worked
am stupid
thx