Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Force effect to run on location change #3283

Merged
merged 1 commit into from
Nov 26, 2021

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Nov 26, 2021

During the migration to react-router v6 in #3119, one of the regression tests was not working correctly. The setTimeout was never running, although it should since the clock is mocked. I tried one workaround of waiting a bit but it was not very reliable. This PR contains the proper fix. It turns out that since the same component is used for every route, React doesn't remount the component so the mount effect never run when the route changes. The mount effect was responsible for running all pending timers. It worked with react-router-dom v5 because, in this version, the route component was cloned before, instead of only returned.

@m4theushw m4theushw added the test label Nov 26, 2021
@m4theushw m4theushw merged commit 40ffb46 into mui:master Nov 26, 2021
@m4theushw m4theushw deleted the force-effect-to-run branch November 26, 2021 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant