react-loads icon indicating copy to clipboard operation
react-loads copied to clipboard

useLoadsCache should be a typed response

Open dwjohnston opened this issue 6 years ago • 0 comments

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.

dwjohnston avatar Sep 12 '19 06:09 dwjohnston