This repository was archived by the owner on Jan 1, 2025. It is now read-only.
Repository navigation
Issues with Generic Type Inference in atomFamily causing duplicate Atom Key errors in Recoil #2325
Unanswered
ArthurGuez
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I’m trying to use Recoil's atomFamily with TypeScript generics to get precise type inference. However, I’m encountering errors related to duplicate atom keys. Here's a simplified version of the code I'm using:
I initially defined my atomFamily like this:
I then modified it to use a generic type:
I use a custom hook to interact with this atom family:
After refactoring to use the generic type, I’m seeing multiple console errors like:
What could be causing these duplicate atom key errors? It seems like using a function to create the atomFamily is leading to these issues. How can I properly use generics with atomFamily without running into duplicate key problems?
All reactions