Repository navigation
Replies: 1 comment
|
For the Retry behavior in your example, hide the error while the resource is loading instead of trying to assign to import { Show, createResource } from 'solid-js'
function App() {
const [data, { refetch }] = createResource(fetcher)
return (
<div>
<p>HELLO WORLD</p>
<Show when={data.loading}>
<p>Loading...</p>
</Show>
<Show when={!data.loading && data.error}>
{error => (
<div role="alert">
<span>{error().message}</span>
<button onClick={() => void refetch()}>Retry</button>
</div>
)}
</Show>
</div>
)
}Keep your In the Solid 1.9.5 implementation, starting an asynchronous reload changes the loading state, while Your reproduction's fetcher always throws after three seconds, so the toast returning after every completed retry is expected. To dismiss a toast without retrying, keep a separate UI dismissal signal; dismissing a notification and changing the resource's failure state are separate actions. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I want to implement a
refetchfunction manually when user clicked the button.currently whenever I got an error from API, i'm showing a toast when the error appear, now i want to add "Retry" button next to a toast message, the problem is toast component always show because of
<Show when={data.error}>current reproduction https://playground.solidjs.com/anonymous/ecd6ac2a-1486-491b-b43b-e52519e559ec
Question: how do i reset the
.errorvalue to null manually? because i don't want to show Toast forever untilrefetchresolve.All reactions