Expire errored payload with `suspense: true`
See original GitHub issueI have an error boundary with a retry button that updates its own key to rerender the whole subtree.
I want to retry the failed request on rerender (I use shouldRetryOnError: false
).
I tried to rethrow the error around useSWR
. I get the logs, but on next render, the xhr request isn’t refired, but SWR reraises the same error as before 😦
try {
console.log("requesting", { key });
result = useSWR(key, fetcher, { suspense: true });
} catch (err) {
console.log("error", { key });
trigger(key);
throw err;
}
const { data, isValidating, revalidate } = result;
Any pointer?
Thx a lot!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Expire errored payload with suspense: true #160 - GitHub
I have an error boundary with a retry button that updates its own key to rerender the whole subtree. I want to retry...
Read more >NextJS not mounting page content on Server Side even using ...
I used useEffect as a trigger, capturing the page's mount event and triggering the function to perform the lazy import, passing the payload...
Read more >Order Completed - DriveWealth Developer Portal
Results Explained ; payload.orderExpires, string, the timestamp of when the order expires ; payload.createdBy, string, userID of who created the order ; payload....
Read more >makeRenderRestHook() - Rest Hooks
readonly error: Error; ... return useSuspense(ArticleResource.get, payload); }); expect(result.current).toBeUndefined(); ... toBe(true);
Read more >Oracle Financials Cloud 20D What's New
However, the opt-in for this feature will expire in 21A. ... accommodation expenses for policy violations and displays the warning and error messages...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @bbenezech, I think the better approach is to clear out cached error in designated error boundary component Here’s a codesandbox example of approach I’ve been using
Couple points to mention:
ErrorGuard
component we clear cached entry when user clicks the button, but we could also just clear it insetState
callback insidecomponentDidCatch
method insteadHi, since #231 got merged you can now clear up the cached error value on your own. For your example it might look something like this: