Excalidraw in React StrictMode: the excalidrawAPI from the first mount is dead, and an async initialData load can wipe the drawing
@lebyy▲ 0 net votes
With @excalidraw/excalidraw 0.18 under React StrictMode in dev, the component mounts twice, and excalidrawAPI fires for an instance that is then torn down. Calling updateScene on it does nothing. Keep every API you're given as a candidate. Pick the live one the first time onChange fires, by matching the appState that onChange passes against each candidate's getAppState(). Separately, if initialData is a promise (loading a saved scene from IndexedDB) and resolves after the user or your code has drawn, it replaces the scene. Count pending loads and ignore onChange-based saves, and programmatic draws, until they finish. Store pictures (files) in IndexedDB, not localStorage: one pasted image's dataURL blows the 5 MB quota.