Skip to content

Commit 79d2d02

Browse files
committed
Use the constructor and fix a bug
1 parent effc632 commit 79d2d02

5 files changed

Lines changed: 27 additions & 6 deletions

File tree

newIDE/app/src/MainFrame/EditorContainers/CustomObjectEditorContainer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export class CustomObjectEditorContainer extends React.Component<RenderEditorCon
5252
gd.ObjectsContainer.Function
5353
);
5454

55+
constructor(props: RenderEditorContainerProps) {
56+
super(props);
57+
this._rebuildProjectScopedContainersAccessor();
58+
}
59+
5560
getProject(): ?gdProject {
5661
return this.props.project;
5762
}
@@ -77,7 +82,6 @@ export class CustomObjectEditorContainer extends React.Component<RenderEditorCon
7782
}
7883

7984
componentDidMount() {
80-
this._rebuildProjectScopedContainersAccessor();
8185
if (this.props.isActive) {
8286
this._setPreviewedLayout();
8387
}

newIDE/app/src/MainFrame/EditorContainers/EventsEditorContainer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export class EventsEditorContainer extends React.Component<RenderEditorContainer
2828
_projectScopedContainersAccessor: ProjectScopedContainersAccessor | null = null;
2929
_scope: EventsScope | null = null;
3030

31+
constructor(props: RenderEditorContainerProps) {
32+
super(props);
33+
this._rebuildProjectScopedContainersAccessor();
34+
}
35+
3136
shouldComponentUpdate(nextProps: RenderEditorContainerProps): any {
3237
// We stop updates when the component is inactive.
3338
// If it's active, was active or becoming active again we let update propagate.
@@ -48,7 +53,6 @@ export class EventsEditorContainer extends React.Component<RenderEditorContainer
4853
}
4954

5055
componentDidMount() {
51-
this._rebuildProjectScopedContainersAccessor();
5256
if (this.props.isActive) {
5357
this._setPreviewedLayout();
5458
}

newIDE/app/src/MainFrame/EditorContainers/ExternalEventsEditorContainer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export class ExternalEventsEditorContainer extends React.Component<
6767
externalPropertiesDialogOpen: false,
6868
};
6969

70+
constructor(props: RenderEditorContainerProps) {
71+
super(props);
72+
this._rebuildProjectScopedContainersAccessor();
73+
}
74+
7075
shouldComponentUpdate(nextProps: RenderEditorContainerProps): any {
7176
// We stop updates when the component is inactive.
7277
// If it's active, was active or becoming active again we let update propagate.
@@ -81,12 +86,12 @@ export class ExternalEventsEditorContainer extends React.Component<
8186
this.props.projectItemName !== prevProps.projectItemName ||
8287
this._associatedLayoutName !== associatedLayoutName
8388
) {
89+
this._associatedLayoutName = associatedLayoutName;
8490
this._rebuildProjectScopedContainersAccessor();
8591
}
8692
}
8793

8894
componentDidMount() {
89-
this._rebuildProjectScopedContainersAccessor();
9095
this.resourceExternallyChangedCallbackId = registerOnResourceExternallyChangedCallback(
9196
this.onResourceExternallyChanged.bind(this)
9297
);
@@ -237,7 +242,7 @@ export class ExternalEventsEditorContainer extends React.Component<
237242
return project.getLayout(layoutName);
238243
}
239244

240-
getAssociatedLayoutName(): ?string {
245+
getAssociatedLayoutName(): string | null {
241246
const { project } = this.props;
242247
if (!project) return null;
243248

newIDE/app/src/MainFrame/EditorContainers/ExternalLayoutEditorContainer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ export class ExternalLayoutEditorContainer extends React.Component<
6666
externalPropertiesDialogOpen: false,
6767
};
6868

69+
constructor(props: RenderEditorContainerProps) {
70+
super(props);
71+
this._rebuildProjectScopedContainersAccessor();
72+
}
73+
6974
getProject(): ?gdProject {
7075
return this.props.project;
7176
}
@@ -94,7 +99,6 @@ export class ExternalLayoutEditorContainer extends React.Component<
9499
}
95100

96101
componentDidMount() {
97-
this._rebuildProjectScopedContainersAccessor();
98102
if (this.props.isActive) {
99103
this._setPreviewedLayout();
100104
}

newIDE/app/src/MainFrame/EditorContainers/SceneEditorContainer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
3030
editor: ?SceneEditor;
3131
_projectScopedContainersAccessor: ProjectScopedContainersAccessor | null = null;
3232

33+
constructor(props: RenderEditorContainerProps) {
34+
super(props);
35+
this._rebuildProjectScopedContainersAccessor();
36+
}
37+
3338
getProject(): ?gdProject {
3439
return this.props.project;
3540
}
@@ -55,7 +60,6 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
5560
}
5661

5762
componentDidMount() {
58-
this._rebuildProjectScopedContainersAccessor();
5963
if (this.props.isActive) {
6064
this._setPreviewedLayout();
6165
}

0 commit comments

Comments
 (0)