From 52bbf168948ef0fcee600da36b568dde6f7f5cf1 Mon Sep 17 00:00:00 2001 From: seyoon20087 <24852454+seyoon20087@users.noreply.github.com> Date: Thu, 23 Jul 2026 19:01:57 +0900 Subject: [PATCH 1/2] Update index.js please see the comments in index.js for more information. Signed-off-by: seyoon20087 <24852454+seyoon20087@users.noreply.github.com> --- src/index.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index 224d269..7bd3716 100644 --- a/src/index.js +++ b/src/index.js @@ -140,6 +140,21 @@ function createLoadableComponent(loadFn, options) { super(props); init(); + // note: i have not put this._loadModule() + // directly in the constructor. + // while running the test (jest) + // i found that putting this._loadModule() in the constructor + // led to undefined behavior, causing almost all tests to fail + // (which may also affect runtime behavior). + // so, i moved only the reporting feature from _loadModule() here, + // but i put the remaining stuff from this._loadModule() + // to componentDidMount below. + if (this.context && Array.isArray(opts.modules)) { + opts.modules.forEach(moduleName => { + this.context.report(moduleName); + }); + } + this.state = { error: res.error, pastDelay: false, @@ -155,21 +170,12 @@ function createLoadableComponent(loadFn, options) { return init(); } - UNSAFE_componentWillMount() { - this._loadModule(); - } - componentDidMount() { this._mounted = true; + this._loadModule(); } _loadModule() { - if (this.context && Array.isArray(opts.modules)) { - opts.modules.forEach(moduleName => { - this.context.report(moduleName); - }); - } - if (!res.loading) { return; } From 3d8a5f381c75500d08e6575dda13baf9f1199de7 Mon Sep 17 00:00:00 2001 From: seyoon20087 <24852454+seyoon20087@users.noreply.github.com> Date: Thu, 23 Jul 2026 20:45:40 +0900 Subject: [PATCH 2/2] Update index.js Signed-off-by: seyoon20087 <24852454+seyoon20087@users.noreply.github.com> --- src/index.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/index.js b/src/index.js index 7bd3716..e94f701 100644 --- a/src/index.js +++ b/src/index.js @@ -139,21 +139,7 @@ function createLoadableComponent(loadFn, options) { constructor(props) { super(props); init(); - - // note: i have not put this._loadModule() - // directly in the constructor. - // while running the test (jest) - // i found that putting this._loadModule() in the constructor - // led to undefined behavior, causing almost all tests to fail - // (which may also affect runtime behavior). - // so, i moved only the reporting feature from _loadModule() here, - // but i put the remaining stuff from this._loadModule() - // to componentDidMount below. - if (this.context && Array.isArray(opts.modules)) { - opts.modules.forEach(moduleName => { - this.context.report(moduleName); - }); - } + this._loadModule(); this.state = { error: res.error, @@ -172,10 +158,15 @@ function createLoadableComponent(loadFn, options) { componentDidMount() { this._mounted = true; - this._loadModule(); } _loadModule() { + if (this.context && Array.isArray(opts.modules)) { + opts.modules.forEach(moduleName => { + this.context.report(moduleName); + }); + } + if (!res.loading) { return; }