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

Fixes #8012 where a race condition with useEffect was causing stale renders of values. #8022

Merged
merged 4 commits into from
Apr 23, 2021

Conversation

brainkim
Copy link
Contributor

@brainkim brainkim commented Apr 22, 2021

Fixes
#6699 (maybe)
#7694
#7896
#8012

A race condition with useEffect was causing stale renders of values when reactivevars were called multiple times synchronously.

@brainkim brainkim requested review from benjamn and jcreighton and removed request for benjamn April 22, 2021 19:59
@brainkim brainkim changed the title Brian 8012 fix Fixes #8012 where a race condition with useEffect was causing stale renders of values. Apr 22, 2021
@brainkim brainkim marked this pull request as draft April 22, 2021 20:05
@brainkim
Copy link
Contributor Author

brainkim commented Apr 22, 2021

Hang on it wasn’t the useLayoutEffect that did it. never mind it was I just didn’t inline consumeAndIterate() right

@brainkim brainkim marked this pull request as ready for review April 22, 2021 20:30
Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think useLayoutEffect is an improvement, but I wonder if we can eliminate the onNextChange listening gap completely? Thoughts below.

src/cache/inmemory/reactiveVars.ts Show resolved Hide resolved
src/react/hooks/useReactiveVar.ts Show resolved Hide resolved
src/cache/inmemory/reactiveVars.ts Show resolved Hide resolved
Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for adding that <StrictMode> test.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants