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

Fix: Optimistic update does not get reset #27453

Merged
merged 1 commit into from
Oct 3, 2023

Commits on Oct 3, 2023

  1. Fix: Optimistic update does not get reset

    I found a bug where if an optimistic update causes a component to
    rerender, and there are no other state updates during that render,
    React bails out without applying the update.
    
    Whenever a hook detects a change, we must mark the component as dirty to
    prevent a bailout. We check for changes by comparing the new state to
    `hook.memoizedState`. However, when implementing optimistic state
    rebasing, I incorrectly reset `hook.memoizedState` to the incoming base
    state, even though I only needed to reset `hook.baseState`. This was
    just a mistake on my part.
    
    This wasn't caught by the existing tests because usually when the
    optimistic state changes, there's also some other state that marks the
    component as dirty in the same render.
    
    I fixed the bug and added a regression test.
    acdlite committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    e6a8f50 View commit details
    Browse the repository at this point in the history