Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b020fb1

Browse files
authored
Check correct commit phase props in fuzz tester (facebook#14129)
Adds a check to the existing fuzz tester to confirm that the props are set to the latest values in the commit phase. Only checks componentDidUpdate; we already have unit tests for the other lifecycles, so I think this is good enough. This is only a redundancy.
1 parent b67c1a2 commit b020fb1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.internal.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ describe('ReactIncrementalTriangle', () => {
189189
leafTriangles.push(this);
190190
}
191191
this.state = {isActive: false};
192+
this.child = React.createRef(null);
192193
}
193194
activate() {
194195
this.setState({isActive: true});
@@ -203,6 +204,14 @@ describe('ReactIncrementalTriangle', () => {
203204
this.state.isActive !== nextState.isActive
204205
);
205206
}
207+
componentDidUpdate() {
208+
if (this.child.current !== null) {
209+
const {prop: currentCounter} = JSON.parse(this.child.current.prop);
210+
if (this.props.counter !== currentCounter) {
211+
throw new Error('Incorrect props in lifecycle');
212+
}
213+
}
214+
}
206215
render() {
207216
if (yieldAfterEachRender) {
208217
ReactNoop.yield(this);
@@ -228,7 +237,7 @@ describe('ReactIncrementalTriangle', () => {
228237
activeDepthProp,
229238
activeDepthContext,
230239
});
231-
return <span prop={output} />;
240+
return <span ref={this.child} prop={output} />;
232241
}
233242

234243
return (

0 commit comments

Comments
 (0)