Closed
Description
In Version 8 the run
method no longer returns a promise. Instead the promise
prop should be used. However, when using useFetch, the promise
property is undefined
.
Here is a test that demonstrates this:
test("defer=true allows using the promise", () => {
let check = 0
const component = (
<Fetch input="/test" options={{ defer: true }}>
{({ run, promise }) => (
<button
onClick={() => {
run()
promise
.then(() => {
return (check = 1)
})
.catch(() => {})
}}
>
run
</button>
)}
</Fetch>
)
const { getByText } = render(component)
fireEvent.click(getByText("run"))
expect(check).toEqual(1)
})
I'll also add a Pull-Request with these failing tests.