Skip to content

Commit 5fedb37

Browse files
committed
#172: Don't use setState in constructor
1 parent 692d88a commit 5fedb37

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/GoogleApiComponent.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ export const wrapper = input => WrappedComponent => {
6767
// Initialize with new options
6868
this.initialize(options);
6969

70-
// Save new options in component state
71-
this.setState({ options: options });
70+
// Save new options in component state,
71+
// and remove information about previous API handlers
72+
this.setState({
73+
options: options,
74+
loaded: false,
75+
google: null
76+
});
7277
}
7378

7479
initialize(options) {
@@ -89,9 +94,6 @@ export const wrapper = input => WrappedComponent => {
8994
// Store information about loading container
9095
this.LoadingContainer =
9196
options.LoadingContainer || DefaultLoadingContainer;
92-
93-
// Remove information about previous API handlers
94-
this.setState({ loaded: false, google: null });
9597
}
9698

9799
onLoad(err, tag) {

0 commit comments

Comments
 (0)