Optimistic response doesn't apply until after the first render cycle
icopp opened this issue · comments
A simple example:
import useLoads from 'react-loads';
export default function WhateverComponent() {
const {
response,
} = useLoads(({ setResponse }) => {
setResponse('pre-value')
return Promise.resolve('value')
});
console.log(response);
return null;
}
The console log will be undefined
, then pre-value
, then value
.
I would expect response
to instead be pre-value
immediately.
Thanks for logging this. It seems that the 'loading' state gets set before the optimistic response. However, it should obviously ideally get set before. I'll have a look into it when I have the time.