v3.0.6
Adds the useManualFetch
hook, which makes a fetch only when triggered manually
Example:
import { useManualFetch, serialize } from 'http-react'
export default function Home() {
const { data, reFetch } = useManualFetch('https://jsonplaceholder.typicode.com/todos/3')
return (
<main>
<button onClick={reFetch}>Request now</button>
<hr />
<pre>{serialize(data, null, 2)}</pre>
</main>
)
}
In this case, while the
Request now
button is not clicked,data
will beundefined