File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ export default function App(props: {
8282 files ?: BinaryFiles
8383 ) => void ;
8484} ) {
85- const excalidrawRef = useRef < ExcalidrawImperativeAPI > ( null ) ;
85+ const [ excalidrawAPI , setExcalidrawAPI ] = useState < ExcalidrawImperativeAPI > ( ) ;
8686 const libraryItemsRef = useRef ( props . libraryItems ) ;
8787 const { theme, setThemeConfig } = useTheme ( props . theme ) ;
8888 const [ imageParams , setImageParams ] = useState ( props . imageParams ) ;
@@ -121,7 +121,7 @@ export default function App(props: {
121121 return ;
122122 }
123123 libraryItemsRef . current = libraryItems ;
124- excalidrawRef . current ! . updateLibrary ( {
124+ excalidrawAPI ? .updateLibrary ( {
125125 libraryItems,
126126 merge : message . merge ,
127127 openLibraryMenu : ! message . merge ,
@@ -157,7 +157,7 @@ export default function App(props: {
157157 return (
158158 < div className = "excalidraw-wrapper" >
159159 < Excalidraw
160- ref = { excalidrawRef }
160+ excalidrawAPI = { ( api ) => setExcalidrawAPI ( api ) }
161161 UIOptions = { {
162162 canvasActions : {
163163 loadScene : false ,
You can’t perform that action at this time.
0 commit comments