react-tree icon indicating copy to clipboard operation
react-tree copied to clipboard

callbacks causing rendering problems

Open peeveen opened this issue 3 years ago • 0 comments

Hi,

The onSelect and onOpenClose callbacks are currently called from within a setState() hook. If I have some code in my callback function to modify my app state (which, in turn, will cause another component to re-render), I get the dreaded "cannot update a component while rendering a different component" error in the console. I've fixed it for now by removing the callbacks, and instead, just having this in the main component body, but there may be a better solution:

image

peeveen avatar Jul 06 '22 14:07 peeveen