On opening this page, I expect to see an rectange in the canvas.
However, I actually get a blank canvas.
After some investigation, I found these events are happening:
initializeScene (in packages/excalidraw/components/App.tsx) is called from componentDidMount. Elements in the scene is set t according to initialData (blank in this example).
The scene is set to have one rectangle via the updateScene API from the function passed to useEffect.
componentDidMount is called again. It calls initializeScene and set the scene to blank again.
I think there should be some guard or something to prevent the 2nd call of initializeScene from initializing things (elements, appState, etc.) that are already initialized/set to fix this issue.
Elements set via
updateScene()
just after getting the API is overwritten toinitialData
.Example code:
On opening this page, I expect to see an rectange in the canvas.
However, I actually get a blank canvas.
After some investigation, I found these events are happening:
initializeScene
(inpackages/excalidraw/components/App.tsx
) is called fromcomponentDidMount
. Elements in the scene is set t according toinitialData
(blank in this example).updateScene
API from the function passed touseEffect
.componentDidMount
is called again. It callsinitializeScene
and set the scene to blank again.I think there should be some guard or something to prevent the 2nd call of
initializeScene
from initializing things (elements, appState, etc.) that are already initialized/set to fix this issue.