@@ -16,10 +16,13 @@ export default function PluginSchema({ pluginContext, showProjectSchema = false
1616 const { project, skeleton } = pluginContext ;
1717
1818 const [ editorSize , setEditorSize ] = useState ( { width : 0 , height : 0 } ) ;
19- const [ schemaValue , setSchemaValue ] = useState ( ( ) => {
19+ const getSchemaStr = useCallback ( ( ) => {
2020 const schema = project . exportSchema ( IPublicEnumTransformStage . Save ) ;
2121 const schemaToShow = showProjectSchema ? schema : schema ?. componentsTree ?. [ 0 ] ;
22- return schemaToShow ? JSON . stringify ( schemaToShow , null , 2 ) : '' ;
22+ return schemaToShow ? JSON . stringify ( schemaToShow , null , 2 ) : '' ;
23+ } , [ ] ) ;
24+ const [ schemaValue , setSchemaValue ] = useState ( ( ) => {
25+ return getSchemaStr ( ) ;
2326 } ) ;
2427 const monacoEditorRef = useRef < IEditorInstance > ( ) ;
2528
@@ -33,9 +36,7 @@ export default function PluginSchema({ pluginContext, showProjectSchema = false
3336 useLayoutEffect ( ( ) => {
3437 const cancelListenShowPanel = skeleton . onShowPanel ( ( pluginName : string ) => {
3538 if ( pluginName == 'LowcodePluginAliLowcodePluginSchema' ) {
36- const schema = project . exportSchema ( IPublicEnumTransformStage . Save ) ;
37- const str = schema ?. componentsTree ?. [ 0 ] ? JSON . stringify ( schema . componentsTree [ 0 ] , null , 2 ) : '' ;
38- setSchemaValue ( str ) ;
39+ setSchemaValue ( getSchemaStr ( ) ) ;
3940 }
4041 } )
4142 return cancelListenShowPanel ;
0 commit comments