We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
initialState
1 parent 8afaeec commit 0e64ae6Copy full SHA for 0e64ae6
src/controller/ApplicationController.tsx
@@ -156,7 +156,7 @@ class ApplicationController<
156
);
157
158
// @ts-ignore
159
- this.state = store(cloneDeep(this.constructor.initialState));
+ this.state = store(cloneDeep(this.initialState));
160
if (this.initialize) this.initialize(initialArgs);
161
this.initialized = true;
162
} else {
@@ -169,6 +169,17 @@ class ApplicationController<
169
*/
170
destroy() {}
171
172
+ /**
173
+ * Creates the initial state of the controller.
174
+ */
175
+ get initialState(): State {
176
+ if ('initialState' in this.constructor) {
177
+ return this.constructor.initialState as State;
178
+ }
179
+
180
+ return {} as State;
181
182
183
/**
184
* Internal destroy function. Do not override
185
* @private
0 commit comments