Created
June 24, 2018 07:59
-
-
Save AndrejGajdos/48322de578fdcc6a13d93ff9c4568fc9 to your computer and use it in GitHub Desktop.
This part is part of project https://github.com/AndrejGajdos/auth-flow-spa-node-react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Header from 'components/Header'; | |
import Routes from 'routes'; | |
import LoginFormModal from 'components/LoginForm'; | |
import './App.scss'; | |
export class App extends Component { | |
state = { | |
error: null, | |
errorInfo: null, | |
}; | |
componentDidCatch(error, errorInfo) { | |
this.setState({ error, errorInfo }); | |
} | |
render() { | |
const { error, errorInfo } = this.state; | |
return ( | |
<div> | |
<Header /> | |
<main> | |
{!error && <Routes />} | |
{error && ( | |
<div className="App__error container mt-3"> | |
<div role="alert" className="alert alert-danger"> | |
<h4>An error occurred. Please reload the page and try again.</h4> | |
<p className="App__stacktrace"> | |
{process.env.NODE_ENV === 'development' && errorInfo.componentStack} | |
</p> | |
</div> | |
</div> | |
)} | |
</main> | |
<LoginFormModal /> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment