-
-
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
DeepResolveType breaks React.ComponentType #292
Comments
A component is not a serializable object, so you may want to use |
i am using ref but the problem is this works fine because you let it infer the type, but it's not a solution because you want to define the type of your store, not infer it from a specific value.
if you try to define it, it breaks
we need a
|
Thanks for the explanation. Yeah, this is asked before, but we avoid to expose Does this work in your use case? const store = proxy({
Comp: ref<React.ComponentType>(() => null),
}) or const store = proxy({
Comp: ref((() => null) as React.ComponentType),
}) But, I now think your first workaround is good enough in the meantime: const snap = useSnapshot(store) as typeof store |
this works, but i have to infer the type from the value. which is not what i want
i want to define the type of my store then use it
while this works, it is not very clean..
|
How about this? I didn't try it though. // we expect this is eliminated with minification.
const dummyRef = ref<React.ComponentType>(() => null)
type RefComponentType = typeof dummyRef
type Store = {
components: RefComponentType[]
} |
There is a TS error |
🤦♂️ |
i'd rather use as typeof store anyways haha |
Sorry for the inconvenience. Thought |
While #333 doesn't solve the use case of this, it avoids using I still think the easy workaround is |
Hi,
useSnapshot uses DeepResolveType as the return type which breaks the type if one of the props is a ref to a ComponentType.
The text was updated successfully, but these errors were encountered: