Replies: 2 comments 4 replies
-
I believe you can achieve this with useRecoilCallback. |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So this might be against the philosophy of recoil, but it would be great if we can create a wrapper for a selector/selectorFamily that would allow it to function as an action.
For example, take the following code:
Any place I want to set the
isOpen
property formodalState
, I have to do the following:It would be nice to have an
Action Factory
that would allow you do something like this:This way, we can simply re-use the action.
You can sort of do something similar, but it's not really the cleanest approach, and requires you to knowingly pass in a value to
selectorFamily
that will not get used:EDIT: Some further context...
Say I wanted to have an action called
closeModal
, that would reset some of themodalState
properties. Would be much easier than having to manually pass that data in as an argument. You could create a selector to do this, but since theget
is non optional, it seems a bit hacky to consider this as an actionBeta Was this translation helpful? Give feedback.
All reactions