Skip to content

provide routes the option to have their props refetched each time the…#488

Draft
infiton wants to merge 1 commit into
mainfrom
make-page-cache-optional
Draft

provide routes the option to have their props refetched each time the…#488
infiton wants to merge 1 commit into
mainfrom
make-page-cache-optional

Conversation

@infiton
Copy link
Copy Markdown

@infiton infiton commented May 10, 2023

@airhorns putting this up to get you take on if this is the right approach

@airhorns
Copy link
Copy Markdown
Collaborator

Yeah this looks like the right approach to me! I think the most react-y way to implement usePromise to actually pay attention to the refetch param would be to use that refetch object in a dependencies array of a useEffect or similar. I didn't try it but I think what you have would work as well.

@infiton
Copy link
Copy Markdown
Author

infiton commented May 11, 2023

The current approach won't work, from facebook/react#17526

The result is then cached. This cache is “append-only”: once we put the fetched data into the cache, we never mutate or remove it. (There is a separate mechanism for invalidation in React itself, which amounts to replacing the cache with an empty one — see https://github.com/reactwg/react-18/discussions/25 for an early look.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants