Cannot delete atomFamily values #1455
Replies: 3 comments 4 replies
-
I don't have time to look into details, but this sounds something challenging. We should come up with good practice. Meanwhile cc'ing @barelyhuman who works on jotai-form. |
Beta Was this translation helpful? Give feedback.
-
https://codesandbox.io/s/jotai-playground-forked-2u8v2h?file=/src/App.tsx It looks like working as expected. (I removed |
Beta Was this translation helpful? Give feedback.
-
Thank you for suggestions @dai-shi @barelyhuman So I guess two ways to achieve this would be:
As I said, I like the easy initialization so I'd rather proceed with the second variant for which I updated the example |
Beta Was this translation helpful? Give feedback.
-
Hey, first of all, thank you for an amazing library!
I am trying to connect jotai with formik to get some performance boost. The idea is to have atomFamily for all the forms
creating formik bag for each of them, propagating it to atom, from where some select-atoms would be derived for fields, actions etc.
Problem is that when navigating from some page with form and then back, formik bag needs to be recreated in order to avoid
can't perform react state update on unmounted
error. I was hoping to achieve such behavior withProvider
, but there seems to be some issue.Here is working example - I would expect that after reloading the page old atom value will be deleted and then recreated.
I also tried to use
atomFamily.remove
when unmounting the components. There are some inconsistencies though - because it 'works' only after clicking the reload button multiple times.I would really appreciate help.
Beta Was this translation helpful? Give feedback.
All reactions