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

Account for another DevTools + Fast Refresh edge case #21523

Merged
merged 1 commit into from
May 19, 2021

Commits on May 19, 2021

  1. Account for another DevTools + Fast Refresh edge case

    DevTools now 'untrack' Fibers (cleans up the ID-to-Fiber mapping) after a slight delay in order to support a Fast Refresh edge case:
    1. Component type is updated and Fast Refresh schedules an update+remount.
    2. flushPendingErrorsAndWarningsAfterDelay() runs, sees the old Fiber is no longer mounted (it's been disconnected by Fast Refresh), and calls untrackFiberID() to clear it from the Map.
    3. React flushes pending passive effects before it runs the next render, which logs an error or warning, which causes a new ID to be generated for this Fiber.
    4. DevTools now tries to unmount the old Component with the new ID.
    
    The underlying problem here is the premature clearing of the Fiber ID, but DevTools has no way to detect that a given Fiber has been scheduled for Fast Refresh. (The '_debugNeedsRemount' flag won't necessarily be set.)
    
    The best we can do is to delay untracking by a small amount, and give React time to process the Fast Refresh delay.
    Brian Vaughn committed May 19, 2021
    Configuration menu
    Copy the full SHA
    6fbca5a View commit details
    Browse the repository at this point in the history