No only Error for FallbackProps
See original GitHub issueI’m using React-query, and we can type our error. But there is a conflit with react-error-boundary since the type is not an Error type, but a custom. How can we deal with that ?
react-error-boundary
version: 3.1.0node
version: 12.19.1npm
version: 6.14.10
Relevant code or config
const OrderDetailsViews = (
props: RouteComponentProps<TParams>
): React.ReactElement => {
const { match } = props
const { t } = useTranslation()
const orderId = Number(match.params.id)
const handleError = useErrorHandler()
const { data: order, error, refetch: refetchOrders } = useQuery<
FindOneOrder,
ApiError
>(['order-details', orderId], () => api.orders.findOneComplete(orderId), {
onError: err => handleError(err) <-- ERROR TYPE
})
}
Suggested solution: We can pass our type like : handleError<ApiError>(err)
OR
interface FallbackProps<T extends Error> { <-- We can pass something else
error: T;
resetErrorBoundary: (...args: Array<unknown>) => void;
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Error Boundaries - React
Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them. Note. Error boundaries do not...
Read more >reset error boundary on back journey using useErrorHandler ...
Provide a key to <ErrorBoundary /> . Whenever the key changes, the error boundary is reset. In your case, using useLocation().pathname as ...
Read more >React Error Boundaries: Complete Guide - Meticulous
A complete guide to implementing React Error Boundaries, and how to use a third-party tool for handling more sophisticated scenarios.
Read more >React Error Boundaries at the Granular Level
The aim is that if an error occurs, navigation should not be ... render() { const fallbackProps = { error: this.state.error, tryAgain: this....
Read more >How to deal with failure in Redux connect ? | by Guillaume Wuip
fallbackProps . The props of a fallback component. If componentProps is there, render the component, if not, render the fallback. // let's ...
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 FreeTop 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
Top GitHub Comments
And I would consider this a bug fix
What is the need for it to be an error ? and not
unknown
like in node?Also see #36 and #25