-
Notifications
You must be signed in to change notification settings - Fork 16
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 error with hot module replacement #264
base: main
Are you sure you want to change the base?
fix error with hot module replacement #264
Conversation
@@ -51,6 +51,10 @@ export function useCachedResponsivePrecommitValue<T>( | |||
const lastCommittedParentCache = useRef<ParentCache<T> | null>(null); | |||
|
|||
useEffect(() => { | |||
if (lastCommittedParentCache.current === parentCache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now see this, btw... I'll investigate what is going on.
My suspicion is that the component cache is caching the old component. I haven't looked into this.
I think in terms of strict mode, we're still likely incompatible. Basically, useLazyReference
will uncommit, dispose, and re-commit, which does not re-issue the query.
I am philosophically opposed to that — queries aren't always re-issuable! But we can probably warn loudly and reissue queries. Just sucks if you're lazily doing a mutation, which is possible :-P
Once #252 lands, there probably won't be a huge need for lazy loaded queries though
Now |
This is not erroring, but the environment cache will indeed produce stale components PS. so if we fix component cache we will receive fresh components, and it shouldn't cause these errors PPS. the issue seems to be components get hot reloaded, but somehow |
When hot module replacement happens the
parentCache
doesn't change butuseEffect
is rerun (don't know what the exact cause of this is), whenuseEffect
is rerun it crashes, because it can't accesscacheItem
anymore.The extra check makes sure effect is run once per
parentCache
(maybe we are compatible withStrictMode
now?)