Provide extra props to fallback component
See original GitHub issueI would like to pass extra props into the fallback component.
My use case:
const _Uploader = lazy(() => import('uploader'));
type Props = { onRequestClose: () => void };
const Uploader: SFC<Props> = props => (
<ErrorBoundary FallbackComponent={MyErrorComponent}>
<Suspense fallback={<MyLoadingComponent {...props} />}>
<_Uploader {...props} />
</Suspense>
</ErrorBoundary>
);
I want my fallback component, MyErrorComponent
, to receive the prop onRequestClose
, in the same way I provide it to MyLoadingComponent
.
Perhaps the fallback component should be provided as a render prop instead of as a Component
?
props => <ErrorBoundary fallback={
({ error }) => <MyErrorComponent error={error} {...props} />
} />
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:16 (8 by maintainers)
Top Results From Across the Web
How to use Error Boundaries with Fallback UI in React - Medium
Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.
Read more >React error handling with react-error-boundary - LogRocket Blog
With react-error-boundary, we can simply wrap components where we expect errors with the provided ErrorBoundary component and pass in some extra ...
Read more >How to allow fallback prop in React error boundary with ...
I have an error boundary on top of my app. It works, and I can pass it a custom component ...
Read more >What you may not know about the Error Boundary
According to the React docs, we use static getDerivedStateFromError() to render a fallback UI after an error has been thrown. Use ...
Read more >React.Component
The render() method is the only required method in a class component. When called, it should examine this.props and this.state and return one...
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
We’re implementing a new
fallbackRender
prop which will allow you to do whatever you’d like:What stops you from passing an inline function component currently?
Here’s an example: https://codesandbox.io/s/zk469wp6jp