You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code in the 10-error-boundaries checkpoint does not seem to work as expected since the <h2> tag with the link back to home is never rendered when hitting a path like http://localhost:1234/details/thisShouldShowTheFallbackPage. I tried console.log()'ing through the different parts of the component and am seeing that only render() is entered and this.props.children is returned immediately which results in a page with the None.jpg image and an ugly undefined-filled details page:
// mostly code from reactjs.org/docs/error-boundaries.htmlimport{Component}from"react";import{Link,Redirect}from"react-router-dom";classErrorBoundaryextendsComponent{state={hasError: false};staticgetDerivedStateFromError(){console.log("getDerivedStateFromError");//Never loggedreturn{hasError: true,redirect: false};}componentDidCatch(error,info){console.log("componentDidCatch");//Never loggedconsole.error("ErrorBoundary caught an error",error,info);}componentDidUpdate(){console.log("componentDidUpdate");//Never loggedif(this.state.hasError){setTimeout(()=>this.setState({redirect: true}),5000);}}render(){console.log("render");//Loggedif(this.state.redirect){console.log("redirect");//Never loggedreturn<Redirectto="/"/>;}elseif(this.state.hasError){console.log("hasError");//Never loggedreturn(<h2>
There was an error with this listing. <Linkto="/">Click here</Link>{" "}
to back to the home page or wait five seconds.
</h2>);}console.log("this.props.children");//Loggedreturnthis.props.children;}}exportdefaultErrorBoundary;
The text was updated successfully, but these errors were encountered:
Its working on my pc
For logging error you need to throw an error throw new Error("lol its broken")
make sure the above code is in render()of Detail.js cause we are looking for error in Details Component.
The code in the 10-error-boundaries checkpoint does not seem to work as expected since the
<h2>
tag with the link back to home is never rendered when hitting a path like http://localhost:1234/details/thisShouldShowTheFallbackPage. I tried console.log()'ing through the different parts of the component and am seeing that onlyrender()
is entered andthis.props.children
is returned immediately which results in a page with the None.jpg image and an uglyundefined
-filled details page:The text was updated successfully, but these errors were encountered: