Nice overview of Recoil. I'm a little confused about your example of a selector with set.

If the selectors is purely derived from the dependent selectors or atoms, I was wondering why it would ever be appropriate to set them? It seems more appropriate to set the atoms and let the selector be recomputed.

Then I looked at the example here on their docs and it seems the selectors don't set the value of themselves, but they call set on their dependent atoms.

set: ({set}, newValue) => set(myAtom, newValue),

However, your example uses a different syntax:

set: ({get, set}) => ... set()

From my understanding, we have greeting atom with a name like "Stephan" and a greetingsMike selector that outputs `${greetings} Mike` which would be like `Stephan Mike`.

Then inside the `set` we're setting greet to `Stephan Mike` which I thought would make like a circular loop of `Stephan Mike Mike Mike Mike Mike Mike ..."

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store