Skip to main content

useRecoilDebouncedValue

Description#

Debounce Recoil state setter.
It is often used with eva-sdk-react-recoil, when a service request changes based on an input value.

Usage#

import { atom } from 'recoil';import { useRecoilDebouncedValue } from '@springtree/eva-suite-react-hooks';
const ExampleAtom = atom<string | undefined>({  key: 'ExampleKey',  default: undefined,});
const Example = () => {  const [inputValue, setInputValue] = useRecoilDebouncedValue(ExampleAtom);
  return (    <>      <input        type="text"        value={inputValue ?? ''}        onChange={(event) => setInputValue(event.target.value)}      >      <span>        {`The current value is: ${inputValue ?? 'undefined'}`}      </span>    </>  );};
export default Example;

References#