From 0de322c58d6feb522ac4f53cc3b24ba9055bb654 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 6 Nov 2018 15:01:18 -0800 Subject: [PATCH] Check correct commit phase props in fuzz tester (#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. --- .../ReactIncrementalTriangle-test.internal.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.internal.js b/packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.internal.js index fd82638be869e..5d11fd65f2f0b 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.internal.js @@ -189,6 +189,7 @@ describe('ReactIncrementalTriangle', () => { leafTriangles.push(this); } this.state = {isActive: false}; + this.child = React.createRef(null); } activate() { this.setState({isActive: true}); @@ -203,6 +204,14 @@ describe('ReactIncrementalTriangle', () => { this.state.isActive !== nextState.isActive ); } + componentDidUpdate() { + if (this.child.current !== null) { + const {prop: currentCounter} = JSON.parse(this.child.current.prop); + if (this.props.counter !== currentCounter) { + throw new Error('Incorrect props in lifecycle'); + } + } + } render() { if (yieldAfterEachRender) { ReactNoop.yield(this); @@ -228,7 +237,7 @@ describe('ReactIncrementalTriangle', () => { activeDepthProp, activeDepthContext, }); - return ; + return ; } return (