-
-
Notifications
You must be signed in to change notification settings - Fork 257
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(vanilla, react): use experimental_use and some refactors #545
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 36a8f1a:
|
Size Change: +1.42 kB (+3%) Total Size: 51.5 kB
ℹ️ View Unchanged
|
This reverts commit 10b8b6b.
src/react.ts
Outdated
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
experimental_use, |
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.
DefinitelyTyped/DefinitelyTyped#62189
It seems that the typing of experimental_use
is now added to the @types/react
, and ts-ignore
could be removed.
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.
According to reactjs/rfcs#229, the use of |
@@ -14,6 +24,38 @@ import type { INTERNAL_Snapshot as Snapshot } from './vanilla' | |||
|
|||
const { useSyncExternalStore } = useSyncExternalStoreExports | |||
|
|||
// customized version of affectedToPathList | |||
// we need to avoid invoking getters |
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.
@dai-shi ahhh, okay, this change (skipping getters in the output of affectedToPathList
) is why I've been confused.
I've been watching the output of useAffectedDebugValue
(maybe a little too religiously in retrospect) and was very confused by the lack of getters.
This made me think "valtio is not working" / "doesn't know my getters were invoked", when obviously I could tell it did, b/c the re-renders still worked correctly.
I finally reproduced the behavior in proxy-compare
and "get it"--getters (and method invocations) are always in the affected map, and are always handled correctly by isChanged
, it is merely affectedToPathList
that is leaving them off.
What was the rationale here? I'm sure it makes sense, just curious b/c it tripped me up. Wondering if I can work the rationale/behavior in a doc/"gotchas" update.
Thanks!
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.
Without it, it loops infinitely and hangs, AFAIR.
Ref: facebook/react#25084
In addition:
PROXY_STATE
.SNAPSHOT
type with Awaited.