1- import React , { useMemo } from "react" ;
1+ import React , { useCallback } from "react" ;
22import { EditorShortcutsProvider } from "./editor-shortcuts-provider" ;
33import { EditorImageRepositoryProvider } from "./editor-image-repository-provider" ;
44import { EditorPreviewDataProvider } from "./editor-preview-provider" ;
@@ -7,14 +7,26 @@ import { EditorToastProvider } from "./editor-toast-provider";
77import { FigmaImageServiceProvider } from "./editor-figma-image-service-provider" ;
88import { FigmaImageServiceProviderForCanvasRenderer } from "./editor-figma-image-service-for-canvas-provider" ;
99import { DashboardStateProvider } from "@code-editor/dashboard" ;
10- import { useEditorState } from "core/states" ;
10+ import { EditorState , useEditorState } from "core/states" ;
1111
1212export function EditorDefaultProviders ( props : { children : React . ReactNode } ) {
1313 const [ state ] = useEditorState ( ) ;
1414
15- const DashboardProvider = useMemo ( ( ) => {
16- return state . design ? DashboardStateProvider : React . Fragment ;
17- } , [ state . design ?. version ] ) ;
15+ const DashboardProvider = useCallback (
16+ ( {
17+ children,
18+ design,
19+ } : React . PropsWithChildren < { design : EditorState [ "design" ] } > ) => {
20+ return state . design ? (
21+ < DashboardStateProvider design = { design } >
22+ { children }
23+ </ DashboardStateProvider >
24+ ) : (
25+ < React . Fragment > { children } </ React . Fragment >
26+ ) ;
27+ } ,
28+ [ state . design ?. version ]
29+ ) ;
1830
1931 return (
2032 < EditorToastProvider >
0 commit comments