Prompt in React 16 "Warning: A history supports only one prompt at a time"
See original GitHub issueVersion
react-router-dom 4.2.2 react 16.0.0
Test Case
https://codesandbox.io/s/rrn9vww8pn
Cause
There is a breaking change in React 16:
When replacing
<A />with<B />,B.componentWillMountnow always happens beforeA.componentWillUnmount. Previously,A.componentWillUnmountcould fire first in some cases.
In the Test Case above each page (Home, About, Topics) has a Prompt component. Because of the asynchronous nature of the React 16 lifecycle, history warns about two prompts being mounted at the same time:
Warning: A history supports only one prompt at a time
At no point in time are there actually two Prompt components “on screen”, but this warning does get triggered.
Issue https://github.com/ReactTraining/history/issues/536 is caused by the same breaking change. Perhaps issue https://github.com/facebook/react/issues/11106 will provide an answer how to resolve this problem.
Issue Analytics
- State:
 - Created 6 years ago
 - Reactions:10
 - Comments:9 (3 by maintainers)
 

Top Related StackOverflow Question
i solved it finnaly promptwrapper.js:
your page.js:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.