uselazyswr
v1.0.1
Published
Tiny react hook wrapped around useSWR to send requests lazily.
Downloads
1
Readme
useLazySWR
Tiny react hook wrapped around useSWR to send requests lazily.
Same API as useSWR except returns an extra execute
function.
Example
import { useLazySWR } from 'uselazyswr';
const App = () => {
const { execute, data } = useLazySWR('/api', fetcher);
return (
<div>
<p>{JSON.stringify(data)}</p>
<button onClick={execute}>Call Api</button>
</div>
);
};