ErrorPage.js (1106B)
1 /** 2 * React Starter Kit (https://www.reactstarterkit.com/) 3 * 4 * Copyright © 2014-present Kriasoft, LLC. All rights reserved. 5 * 6 * This source code is licensed under the MIT license found in the 7 * LICENSE.txt file in the root directory of this source tree. 8 */ 9 10 import React, { PropTypes } from 'react'; 11 import withStyles from 'isomorphic-style-loader/lib/withStyles'; 12 import s from './ErrorPage.css'; 13 14 class ErrorPage extends React.Component { 15 static propTypes = { 16 error: PropTypes.shape({ 17 name: PropTypes.string.isRequired, 18 message: PropTypes.string.isRequired, 19 stack: PropTypes.string.isRequired, 20 }).isRequired, 21 }; 22 23 render() { 24 if (__DEV__) { 25 const { error } = this.props; 26 return ( 27 <div> 28 <h1>{error.name}</h1> 29 <p>{error.message}</p> 30 <pre>{error.stack}</pre> 31 </div> 32 ); 33 } 34 35 return ( 36 <div> 37 <h1>Error</h1> 38 <p>Sorry, a critical error occurred on this page.</p> 39 </div> 40 ); 41 } 42 } 43 44 export { ErrorPage as ErrorPageWithoutStyle }; 45 export default withStyles(s)(ErrorPage);