You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you mount <Tree dndRootElement={dndRootElement.current} /> when dndRootElement.current is null, changes will not be picked up when dndRootElement.current start to refer to a real element.
The text was updated successfully, but these errors were encountered:
Maybe someone finds this useful. I don't know whether I did it optimally, but I wrote a custom hook to timeout rendering of children before the container is mounted.
import{useEffect,useState}from'react';constuseIsParentMounted=(): boolean=>{const[isParentMounted,setIsParentMounted]=useState(false);useEffect(()=>{// Delay rendering of the childconsttimeout=setTimeout(()=>{setIsParentMounted(true);},0);// Ensures the parent is mounted firstreturn()=>clearTimeout(timeout);},[]);returnisParentMounted;};exportdefaultuseIsParentMounted;
Now the <Tree /> can be rendered only after the parent container is mounted and has a non-null reference:
If you mount
<Tree dndRootElement={dndRootElement.current} />
whendndRootElement.current
isnull
, changes will not be picked up whendndRootElement.current
start to refer to a real element.The text was updated successfully, but these errors were encountered: