Skip to content
Discussion options

You must be logged in to vote
export const useRecent = () => {
    const {data, error} = useSWR(
        `${config.apiUrl}/GetRecentFoundations`,
       // Only when component is mounted, swr can have this function to do refetching
        getThenResolve,
        recentOptions
    );

    return {
        recent: data,
        isLoading: !error && !data,
        isError: error
    };
}

export const setRecent = async(fid) => {
    await postThenResolve(
        `${config.apiUrl}/SetFoundationRecent`,
        {fid});
    // what you do here is same as mutate(`${config.apiUrl}/GetRecentFoundations`, undefined, true)
    // The cahce wont be update because the data is undefined
    // when component is not mounted, swr w…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@cmagoun
Comment options

Answer selected by cmagoun
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants