FallbackComponent not rendering
See original GitHub issueRelevant code:
function ErrorFallback({ error }) {
return (
<div role="alert">
<p>Something went wrong:</p>
<pre style={{ color: "red" }}>{error.message}</pre>
</div>
);
}
return (
<ErrorBoundary
FallbackComponent={ErrorFallback}
onReset={() => window.sessionStorage.clear()}
onError={(error) => {
console.log(error);
}}
>
<button onClick={( ) => {throw new Error("Testing with an error")}}>Error thrower</button>
</ErrorBoundary>
When I click on the button that triggers an error the FallbackComponent doesn’t render, even though the error gets logged(onError recognises it). Am I missing something?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
Error boundary fallback ui not rendering in react?
The componentDidCatch not firing. I expected that the fallback UI will render but actually the original UI is still there and nothing is ......
Read more >Fallback component not shown · Issue #116 - GitHub
Fallback component not shown #116 ... import React, { Component, useState, useEffect } from 'react'; import { render } from 'react-dom'; ...
Read more >Blank Thoughts: exercise 7 (fallback component not rendering ...
Hi guys I`ve got in trouble with exercise seven: <ErroBoundary FallbackComponent={(props) => { return <FallbackUI {...props} newProp={"foo"} ...
Read more >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 >Error Boundaries - React
Component ; static getDerivedStateFromError(error) { ; // Update state so the next render will show the fallback UI. ; return { hasError: true...
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
error boundary doesn’t catch error in event handler, if you want catch error in event handler try to use useErrorHandler hook. https://reactjs.org/docs/error-boundaries.html#introducing-error-boundaries
@JonhnyDev Can you provide the code for the child component that’s throwing the error that doesn’t get caught by the error boundary?