Recoil
Recoil copied to clipboard
Atom effects not calling onSet() in Strict Mode
When running in strict mode under React 18, when I subscribe the onSet callback in an effect it does not get called. For a reproduction, see the console of this sample: https://codesandbox.io/s/adoring-euclid-iyvhbt?file=/src/App.tsx If you comment out the strict mode tags then the console log will display the message.
The problem seems to be related to this block. When in strict mode the component is unmounted and remounted, during unmounting the subcriptions generated by onSet are removed but during remounting the effect seems not to be subscribed again.