Skip to content

Commit 2c6fea7

Browse files
liujupingJackLian
authored andcommitted
fix: fix the problem that the schema panel at the project level is displayed incorrectly
1 parent 9622141 commit 2c6fea7

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

packages/plugin-schema/src/editor.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)