Skip to content

Commit 14390f0

Browse files
authored
fix: Optimize the initialization method for masterPaneController (alibaba#2333)
1 parent 2bbb409 commit 14390f0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/plugin-outline-pane/src/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export function OutlinePaneContext(props: {
1818
hideFilter?: boolean;
1919
}) {
2020
const treeMaster = props.treeMaster || new TreeMaster(props.pluginContext, props.options);
21-
const [masterPaneController, setMasterPaneController] = useState(new PaneController(props.paneName || MasterPaneName, treeMaster));
21+
const [masterPaneController, setMasterPaneController] = useState(
22+
() => new PaneController(props.paneName || MasterPaneName, treeMaster),
23+
);
2224
useEffect(() => {
2325
return treeMaster.onPluginContextChange(() => {
2426
setMasterPaneController(new PaneController(props.paneName || MasterPaneName, treeMaster));
@@ -40,7 +42,9 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
4042
const { skeleton, config, canvas, project } = ctx;
4143

4244
let isInFloatArea = true;
43-
const hasPreferenceForOutline = config.getPreference().contains('outline-pane-pinned-status-isFloat', 'skeleton');
45+
const hasPreferenceForOutline = config
46+
.getPreference()
47+
.contains('outline-pane-pinned-status-isFloat', 'skeleton');
4448
if (hasPreferenceForOutline) {
4549
isInFloatArea = config.getPreference().get('outline-pane-pinned-status-isFloat', 'skeleton');
4650
}
@@ -160,4 +164,4 @@ OutlinePlugin.meta = {
160164
],
161165
},
162166
};
163-
OutlinePlugin.pluginName = 'OutlinePlugin';
167+
OutlinePlugin.pluginName = 'OutlinePlugin';

0 commit comments

Comments
 (0)