Skip to content

Commit 0515f73

Browse files
authored
Merge pull request #1716 from FormidableLabs/bug/events-in-strict-mode
Bug/events in strict mode
2 parents 23a65fc + 0b6b25f commit 0515f73

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

demo/js/app.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ class App extends React.Component {
121121
);
122122
})}
123123
</ul>
124-
<Child />
124+
<React.StrictMode>
125+
<Child />
126+
</React.StrictMode>
125127
</div>
126128
);
127129
}

packages/victory-core/src/victory-util/add-events.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,21 @@ export default (WrappedComponent, options) => {
4545
}
4646
const calculatedState = this.getStateChanges(nextProps, calculatedValues);
4747
if (!isEqual(this.calculatedState, calculatedState)) {
48-
this.calculatedState = calculatedState;
49-
this.cacheValues(calculatedValues);
5048
return true;
5149
}
5250
if (!isEqual(this.props, nextProps)) {
53-
this.cacheValues(calculatedValues);
5451
return true;
5552
}
5653
return false;
5754
}
5855

56+
componentDidUpdate(prevProps) {
57+
const calculatedValues = this.getCalculatedValues(prevProps);
58+
const calculatedState = this.getStateChanges(prevProps, calculatedValues);
59+
this.calculatedState = calculatedState;
60+
this.cacheValues(calculatedValues);
61+
}
62+
5963
// compile all state changes from own and parent state. Order doesn't matter, as any state
6064
// state change should trigger a re-render
6165
getStateChanges(props, calculatedValues) {

0 commit comments

Comments
 (0)