noWait(state)

A selector helper that will return a Loadable for the current state of the provided atom or selector.

function noWait<T>(state: RecoilValue<T>): RecoilValueReadOnly<Loadable<T>>

This helper can be used to obtain the current state of a potentially asynchronous dependency without throwing if there is an error or the dependency is still pending. It is similar to useRecoilValueLoadable() except that it is a selector instead of a hook. Because noWait() returns a selector, it can in turn be used by other Recoil selectors as well as hooks.

Example

const myQuery = selector({
key: 'MyQuery',
get: ({get}) => {
const loadable = get(noWait(dbQuerySelector));
return {
hasValue: {data: loadable.contents},
hasError: {error: loadable.contents},
loading: {data: 'placeholder while loading'},
}[loadable.state];
}
})