CHANGELOG-recoil.md
Add new changes here as they land
useRecoilCallback() (#2075)RecoilEnv.RECOIL_GKS_ENABLED (#2078)useSyncExternalStore() (#2001, #2010)RecoilEnv from the recoil package, and set RecoilEnv.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED = false in code to disable the checking and logging.process.env.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=false in NodeJS environments such as NextJsparentStoreID_UNSTABLE to atom effects which is the ID of the parent store it cloned from, such as the host <RecoilRoot> store for useRecoilCallback() snapshots. (#1744)children prop to <RecoilRoot> and useRecoilBridgeAcrossReactRoots_UNSTABLE() for TypeScript for @types/react with React 18 (#1718, #1717, #1726, #1731)toJSON(). (#1709, #1703)<RecoilRoot>'s. (#1712)default value is now optional for atom() and atomFamily(). If not provided the atom will initialize to a pending state. (#1639)getStoreID() method to Snapshot (#1612)RecoilLoadable.loading() factory for making an async Loadable which never resolves. (#1641)get() and Atom's default can now accept a Loadable to put the node in that state.
If you wish to store a Loadable, Promise, or RecoilValue directly you can wrap it with selector.value() or atom.value(). (#1640)useRecoilCallback() now provides a snapshot for the latest state instead of the latest rendered state, which had bugs (#1610, #1604)setSelf() from onSet() handlers. (#1589, #1582)Window interface. (#1571)<StrictMode> (#1473, #1444, #1509).useTransition() using hooks with _TRANSITION_SUPPORT_UNSTABLE suffix. (#1572, #1560)refresh() to the useRecoilCallback() interface for refreshing selector caches. (#1413)getCallback() can now mutate, refresh, and transact Recoil state, in addition to reading it, for parity with useRecoilCallback(). (#1498)<RecoilRoot> and Snapshot stores accessible via useRecoilStoreID() hook (#1417) or storeID parameter for atom effects (#1414).RecoilLoadable.all() and RecoilLoadable.of() now accept either literal values, async Promises, or Loadables. (#1455, #1442).isRetained() method for Snapshots and check if snapshot is already released when using .retain() (#1546)useRecoilTransaction_UNSTABLE() (#1466, #1569)onSet() handlers in atom effects when atoms are cleaned up. (#1509)onSet() when atoms are initialized with <RecoilRoot initializeState={...} > (#1519, #1511)<RecoilRoot> will only call initializeState() once during the initial render. (#1372)useGetRecoilValueInfo_UNSTABLE() and Snapshot#getInfo_UNSTABLE() results (#1549)effects_UNSTABLE to just effects, as the interface is mostly stabilizing. (#1520)<RecoilRoot initializeState={...} >. (#1509)useGetRecoilValueInfo_UNSTABLE() and Snapshot#getInfo_UNSTABLE() always report the node type. (#1547)useRecoilRefresher_UNSTABLE() hook which forces a selector to re-run it's get(), and is a no-op for an atom. (#972, #1294, #1302)getLoadable(), getPromise(), and getInfo_UNSTABLE() to Atom Effects interface for reading other atoms. (#1205, #1210)isReset parameter to onSet() callback to know if the atom is being reset or not. (#1358, #1345)Loadable improvements:
RecoilLoadable interface with factories and type checking for Loadables. (#1263, #1264, #1312)cachePolicy_UNSTABLE option for selectors and selector families. This option allows you to control the behavior of how the selector evicts entries from its internal cache.useRecoilTransaction_UNSTABLE() hook for transactions with multiple atoms (#1085)selectorFamily(), getCallback(), useGetRecoilValueInfo(), and Snapshot#getNodes() (#1060, #1116, #1123)Snapshot (#1135, #1107)For supporting garbage collection in the future there is a slight breaking change that Snapshot's will only be valid for the duration of the callback or render. A new retain() API can be used to persist them longer. This is not enforced yet, but Recoil will now provide a warning in dev-mode if a Snapshot is used past its lifetime. (#1006)
override prop to <RecoilRoot> (#973)getCallback() to selector evaluation interface (#989)Loadables (#966, #1022)<ErrorBoundary>'s (#998, #1017)onSet() should not be called when triggered from setSelf() initializing with a Promise or from the same onSet() handler. (#974, #979, #953, #986)useRecoilCallback() getting current state (#260) - Thanks @drarmstratomFamily and selectorFamily: these provide a standard way to create atoms and selectors using memoized functions. Compared with doing this yourself, in the future these will help with memory management.noWait, waitForNone, waitForAny, waitForAll: helpers for concurrency and other advanced logic in async selectors.constSelector and errorSelector: selectors that always evaluate to a constant or always throw an error.readOnlySelector: wraps a read-write atom or selector in a read-only interface, for when you need type covariance.