Skip to content

Commit

Permalink
Add another (failing) regression test for facebook#14188
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and sophiebits committed Dec 6, 2018
1 parent 8df4d59 commit 5c306e6
Showing 1 changed file with 44 additions and 0 deletions.
Expand Up @@ -222,4 +222,48 @@ describe('ReactDOMSuspensePlaceholder', () => {
await Lazy;
expect(log).toEqual(['cDU first', 'cDU second']);
});

// Regression test for https://github.com/facebook/react/issues/14188
it('can call findDOMNode() in a suspended component commit phase (#2)', () => {
let suspendOnce = Promise.resolve();
function Suspend() {
if (suspendOnce) {
let promise = suspendOnce;
suspendOnce = null;
throw promise;
}
return null;
}

const log = [];
class Child extends React.Component {
componentDidMount() {
log.push('cDM');
ReactDOM.findDOMNode(this);
}

componentDidUpdate() {
log.push('cDU');
ReactDOM.findDOMNode(this);
}

render() {
return null;
}
}

function App() {
return (
<Suspense fallback="Loading">
<Suspend />
<Child />
</Suspense>
);
}

ReactDOM.render(<App />, container);
// expect(log).toEqual([]);
ReactDOM.render(<App />, container);
// expect(log).toEqual(['cDM']);
});
});

0 comments on commit 5c306e6

Please sign in to comment.