GitHub image
recoil
⌘K
Exports
Readme
Functions
20
atom
Docs
Import
Tests
3
References
2

Creates an atom, which represents a piece of writeable state

function atom<T'>(options: AtomOptions<T'>): RecoilState<T'>
selector
Docs
Import
Tests
3
References
2

Creates a selector which represents derived state.

function selector<T'>(options: ReadWriteSelectorOptions<T'>): RecoilState<T'>+1
useRecoilValue
Docs
Import
Tests
3
References
2

Returns the value of an atom or selector (readonly or writeable) and subscribes the components to future updates of that state.

function useRecoilValue<T'>(recoilValue: RecoilValue<T'>): T'
useRecoilValueLoadable
Docs
Import
Tests
3
References
2

Returns a Loadable representing the status of the given Recoil state and subscribes the component to future updates of that state. Useful for working with async selectors.

function useRecoilValueLoadable<T'>(recoilValue: RecoilValue<T'>): Loadable<T'>
useRecoilState
Docs
Import
Tests
3
References
2

Returns a tuple where the first element is the value of the recoil state and the second is a setter to update that state. Subscribes component to updates of the given state.

function useRecoilState<T'>(recoilState: RecoilState<T'>): [T', SetterOrUpdater<T'>]
useRecoilStateLoadable
Docs
Import
Tests
3
References
2

Returns a tuple where the first element is a Loadable and the second element is a setter function to update the given state. Subscribes component to updates of the given state.

function useRecoilStateLoadable<T'>(
recoilState: RecoilState<T'>
): [Loadable<T'>, SetterOrUpdater<T'>]
useSetRecoilState
Docs
Import
Tests
3
References
2

Returns a setter function for updating Recoil state. Does not subscribe the component to the given state.

function useSetRecoilState<T'>(recoilState: RecoilState<T'>): SetterOrUpdater<T'>
useResetRecoilState
Docs
Import
Tests
3
References
2

Returns a function that will reset the given state to its default value.

function useResetRecoilState(recoilState: RecoilState<any>): Resetter
useGetRecoilValueInfo_UNSTABLE
Docs
Import
Tests
3
References
2

Returns current info about an atom

function useGetRecoilValueInfo_UNSTABLE(): <T'>(
recoilValue: RecoilValue<T'>
) => RecoilStateInfo<T'>
useRecoilCallback
Docs
Import
Tests
3
References
2

Returns a function that will run the callback that was passed when calling this hook. Useful for accessing Recoil state in response to events.

function useRecoilCallback<Args', Return'>(
fn: (
interface: Readonly<
{
set: <T'>(
recoilVal: RecoilState<T'>,
valOrUpdater: T' | (currVal: T') => T'
) => void
reset: (recoilVal: RecoilState<any>) => void
snapshot: Snapshot
gotoSnapshot: (snapshot: Snapshot) => void
transact_UNSTABLE: () => void
},
>
) => (args: Args') => Return',
deps?: ReadonlyArray<unknown>
): (args: Args') => Return'
useRecoilTransaction_UNSTABLE
Docs
Import
Tests
3
References
2

Returns a function that executes an atomic transaction for updating Recoil state.

function useRecoilTransaction_UNSTABLE<Args'>(
fn: (interface: TransactionInterface_UNSTABLE) => (args: Args') => void,
deps?: ReadonlyArray<unknown>
): (args: Args') => void
useRecoilTransactionObserver_UNSTABLE
Docs
Import
Tests
3
References
2
function useRecoilTransactionObserver_UNSTABLE(
callback: (opts: { snapshot: Snapshot, previousSnapshot: Snapshot }) => void
): void
useGotoRecoilSnapshot
Docs
Import
Tests
3
References
2

Updates Recoil state to match the provided snapshot.

function useGotoRecoilSnapshot(): (snapshot: Snapshot) => void
useRecoilSnapshot
Docs
Import
Tests
3
References
2

Returns a snapshot of the current Recoil state and subscribes the component to re-render when any state is updated.

function useRecoilSnapshot(): Snapshot
useRecoilRefresher_UNSTABLE
Docs
Import
Tests
3
References
2

Clears the cache for a selector causing it to be reevaluated.

function useRecoilRefresher_UNSTABLE(recoilValue: RecoilValue<any>): () => void
useRecoilBridgeAcrossReactRoots_UNSTABLE
Docs
Import
Tests
3
References
2

Returns a component that acts like a but shares the same store as the current .

function useRecoilBridgeAcrossReactRoots_UNSTABLE(): any
isRecoilValue
Docs
Import
Tests
3
References
2

Returns true if the parameter is a Recoil atom or selector.

function isRecoilValue(val: unknown): boolean
atomFamily
Docs
Import
Tests
3
References
2

Returns a function which returns a memoized atom for each unique parameter value.

function atomFamily<T', P'>(
options: AtomFamilyOptions<T', P'>
): (param: P') => RecoilState<T'>
selectorFamily
Docs
Import
Tests
3
References
2

Returns a function which returns a memoized atom for each unique parameter value.

function selectorFamily<T', P'>(): (param: P') => RecoilState<T'>+1
constSelector
Docs
Import
Tests
3
References
2

Returns a selector that always has a constant value.

function constSelector<T'>(constant: T'): RecoilValueReadOnly<T'>
Description
Recoil - A state management library for React
Install
yarn add recoil
Copy
Details
MIT License
1 Dependencies
Bundles TypeScript Types
Metrics
Weekly Downloads
Keywords