Recoil icon indicating copy to clipboard operation
Recoil copied to clipboard

Atom effects not calling onSet() in Strict Mode

Open juanevp opened this issue 2 years ago • 3 comments

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.

juanevp avatar Oct 28 '22 03:10 juanevp