Skip to main content

Recoil 0.3.0

We are pleased to announce the release of Recoil 0.3.0.

New Features#

  • You can now create a RecoilRoot that falls through to the surrounding root if one exists. This lets you create re-usable components that use Recoil, yet can be used within or without the context of a larger Recoil app. (#973)
  • You can now return Recoil callbacks from selectors. (#989)

Breaking Change: Preparing for Memory Management#

The next release of Recoil will have a breaking API change. Today's release issues a console warning in development builds if you have any code that will need to be updated. Most apps will not need any code changes.

When we ship memory management, Snapshots (such as the one you get as an argument to useRecoilCallback()) will only be valid for the tick in which they are created. If you want to keep a Snapshot around for longer, you need to manually retain and then release it:

const release = snapshot.retain();
try {
await someAsyncWork(snapshot);
} finally {

In 0.3.0, if you use a Snapshot that hasn't been retained, you will get a console warning in development. There is no change in behavior in production. In the next release, it will throw an exception, in both development and production.

Retaining Snapshots should be avoided whenever possible, because it will prevent reclaiming of memory for all atoms for as long as that Snapshot is retained. Instead, pull out just the values you need before going to async.

Bug Fixes, Performance, and Other Improvements#

  • Reduced overhead when using atomFamily. One app with thousands of atoms saw 200MB less memory usage.
  • Fix a bug where errors throws from async selectors were not caught by React error boundaries. (#998, #1017)
  • Experimental Atom Effects onSet() is no longer called when triggered from setSelf() initializing with a Promise or from the same onSet() handler. (#974, #979, #953, #986)
  • Improved support for Safari. (#967, #609)
  • Values stored in selectors are now frozen in dev mode. (#911)
  • Improved TypeScript support for Loadables.