This package contains multiple hooks that can be used in your React application!
npm install @nanlabs/react-hooks
The following example shows how one of the multiple hooks provided by this library can be used.
In the example bellow we use useDebounce
to debounce the value of an input.
You can find more examples in the documentation.
import React, { useState } from "react";
import { useDebounce } from "@nanlabs/react-hooks";
const Component = () => {
const [value, setValue] = useState("");
const debouncedValue = useDebounce(value, 500);
return (
<div>
<input value={value} onChange={(e) => setValue(e.target.value)} />
<p>Debounced value: {debouncedValue}</p>
</div>
);
};