Skip to content

Commit 1bd02fb

Browse files
authored
Merge pull request #972 from narenranjit/patch-1
Fix equality check for lazy-loading example
2 parents 9a135ca + 0389d1b commit 1bd02fb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

content/guides/lazy-load-react.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ class LazilyLoad extends React.Component {
8383
}
8484

8585
componentDidUpdate(previous) {
86-
if (this.props.modules === previous.modules) return null;
87-
this.load();
86+
const shouldLoad = !!Object.keys(this.props.modules).filter((key)=> {
87+
return this.props.modules[key] !== previous.modules[key];
88+
}).length;
89+
if (shouldLoad) {
90+
this.load();
91+
}
8892
}
8993

9094
componentWillUnmount() {

0 commit comments

Comments
 (0)