question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prompt in React 16 "Warning: A history supports only one prompt at a time"

See original GitHub issue

Version

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.componentWillMount now always happens before A.componentWillUnmount. Previously, A.componentWillUnmount could 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:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
katelicommented, Jul 2, 2018

i solved it finnaly promptwrapper.js: image

your page.js: image

0reactions
stale[bot]commented, Sep 10, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom React Router Prompt: A history supports only one ...
Everything seems to be working as it should, but I have an annoying warning: Warning: A history supports only one prompt at a...
Read more >
Prompt in React 16 "Warning: A history supports only one ...
At no point in time are there actually two Prompt components "on screen", but this warning does get triggered. Issue remix-run/history#536 ...
Read more >
Custom React Router Prompt: A history supports only one ...
Coding example for the question Custom React Router Prompt: A history supports only one prompt at a time-Reactjs.
Read more >
A history supports only one prompt at a time - Bountysource
Prompt in React 16 "Warning: A history supports only one prompt at a time"
Read more >
Hey Firda, I got it to work nicely. However this block throws a ...
Custom React Router Prompt ... setCurrentPath(prompt.pathname) ... tiny-warning.esm.js:11 Warning: A history supports only one prompt at a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found