-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add info about error casting in in createResource #1086
base: main
Are you sure you want to change the base?
Add info about error casting in in createResource #1086
Conversation
|
✅ Deploy Preview for solid-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
<Callout title="Note"> | ||
|
||
If you anticipate errors, you may want to wrap `createResource` in an [ErrorBoundary](/reference/components/error-boundary). | ||
|
||
</Callout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is out of place but I couldn't find a better place for it. It shouldn't be here in the first place. Maybe we should mention it somewhere here instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - probably best to add under Using createResource
✅ Deploy Preview for solid-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
||
As of **v1.4.0**, `data.latest` will return the last returned value and won't trigger [Suspense](/reference/components/suspense) and [transitions](#TODO); if no value has been returned yet, `data.latest` acts the same as `data()`. | ||
This can be useful if you want to show the out-of-date data while the new data is loading. | ||
- `data.loading` tells you if the fetcher has been called but not returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `data.loading` tells you if the fetcher has been called but not returned. | |
- `data.loading`: whether the fetcher has been called but not returned. |
As of **v1.4.0**, `data.latest` will return the last returned value and won't trigger [Suspense](/reference/components/suspense) and [transitions](#TODO); if no value has been returned yet, `data.latest` acts the same as `data()`. | ||
This can be useful if you want to show the out-of-date data while the new data is loading. | ||
- `data.loading` tells you if the fetcher has been called but not returned. | ||
- `data.error` tells you if the request has errored out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `data.error` tells you if the request has errored out. | |
- `data.error`: if the request has errored out. |
This can be useful if you want to show the out-of-date data while the new data is loading. | ||
- `data.loading` tells you if the fetcher has been called but not returned. | ||
- `data.error` tells you if the request has errored out. | ||
`createResource` always provides an `Error` object for `data.error`, even if the fetcher throws something else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`createResource` always provides an `Error` object for `data.error`, even if the fetcher throws something else. | |
`createResource`: provides an `Error` object for `data.error`. It will show even if the fetcher throws something else. |
- If the fetcher throws an `Error` instance, `data.error` will be that instance. | ||
- If the fetcher throws a string, `data.error.message` will contain that string. | ||
- If the fetcher throws a value that is neither an `Error` nor a string, that value will be available as `data.error.cause`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If the fetcher throws an `Error` instance, `data.error` will be that instance. | |
- If the fetcher throws a string, `data.error.message` will contain that string. | |
- If the fetcher throws a value that is neither an `Error` nor a string, that value will be available as `data.error.cause`. | |
- Fetcher throws an `Error` instance, `data.error` will be that instance. | |
- If the fetcher throws a string, `data.error.message` will contain that string. | |
- When the fetcher throws a value that is neither an `Error` nor a string, that value will be available as `data.error.cause`. |
<Callout title="Note"> | ||
|
||
If you anticipate errors, you may want to wrap `createResource` in an [ErrorBoundary](/reference/components/error-boundary). | ||
|
||
</Callout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - probably best to add under Using createResource
|
||
</Callout> | ||
|
||
- As of **v1.4.0**, `data.latest` will return the last returned value and won't trigger [Suspense](/reference/components/suspense) and [transitions](#TODO); if no value has been returned yet, `data.latest` acts the same as `data()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- As of **v1.4.0**, `data.latest` will return the last returned value and won't trigger [Suspense](/reference/components/suspense) and [transitions](#TODO); if no value has been returned yet, `data.latest` acts the same as `data()`. | |
- As of **v1.4.0**, `data.latest` returns the last value received and will not trigger [Suspense](/reference/components/suspense) or [transitions](#TODO); if no value has been returned yet, `data.latest` will act the same as `data()`. |
Description(required)
This PR adds more information about how
createResource
casts errors.Related issues & labels
castError
behavior ofcreateResource
should be documented #825