react-loads
react-loads copied to clipboard
useLoadsCache should be a typed response
Similar to other issues.
if I do
Somewhere:
export async function fetchUser() : Promise<User> {
return new Promise((res, rej) => {
setTimeout(() => {
res({
userId: 101
});
}, 1000)
});
}
const loadUser = useCallback(fetchUser, []);
...
const { response: userResponse, isPending: userIsPending, } = useLoads(loadUser, {
context: 'user'
});
Elsewhere
const user = useLoadsCache('user');
The signature should be the same as the the function I pased to useLoads, ie User | undefined.