softobiz-lazy-input
v1.0.2
Published
A simple react component that accepts a callback and trigger it on a delay after user stops typing
Downloads
2
Readme
Softobiz-Lazy-Input
This componet can be used as a search input comopnent where you want to optimize your serach api calls. Its takes a callback function which is get triggered when stop typing on in it.
Installation
npm install softobiz-lazy-input
Usage
In the browser
import { useState } from "react";
import { LazyInput } from "softobiz-lazy-input";
function App() {
const [value, setValue] = useState("");
const handleLazyChange = () => {
// you can write your code or api calls here
console.log(value);
};
return (
<div>
<LazyInput
value={value}
onChange={(e) => setValue(e.target.value)}
onLazyChange={handleLazyChange}
delay={500}
/>
</div>
);
}
const root = createRoot(document.getElementById("root"));
root.render(<App />);