Guest User

Untitled

a guest
Jun 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. class App extends Component {
  2. render() {
  3. // here
  4. throw new Error("trol");
  5. return (
  6. <div className="App">
  7. <header className="App-header">
  8. <h1 className="App-title">Welcome to React</h1>
  9. </header>
  10. <p className="App-intro">
  11. To get started, edit <code>src/App.js</code> and save to reload.
  12. </p>
  13. </div>
  14. );
  15. }
  16. }
  17.  
  18. export default App;
  19.  
  20. export default class ErrorBoundary extends React.Component {
  21. constructor(props) {
  22. super(props);
  23. this.state = { hasError: false };
  24. }
  25.  
  26. componentDidCatch(error, info) {
  27. // Display fallback UI
  28. this.setState({ hasError: true });
  29. // You can also log the error to an error reporting service
  30. //logErrorToMyService(error, info);
  31. }
  32.  
  33. render() {
  34. if (this.state.hasError) {
  35. // You can render any custom fallback UI
  36. return <h1>Something went wrong.</h1>;
  37. } else {
  38. return this.props.children;
  39. }
  40.  
  41. }
  42. }
  43.  
  44. export const renderRoutes = () => (
  45. <ErrorBoundary>
  46. <App />
  47. </ErrorBoundary>
  48. );
  49.  
  50. Meteor.startup(() => {
  51. render(renderRoutes() , document.getElementById('render-target'));
  52. });
  53.  
  54. onPageLoad(sink => {
  55. const html = "<div id='render-target'>" + renderToString(
  56. <ErrorBoundary>
  57. <App />
  58. </ErrorBoundary>
  59. ) + "</div>";
  60. sink.appendToBody(html);
  61. });
  62.  
  63.  
  64. Meteor.startup(() => {
  65. // code to run on server at startup
  66. });
  67.  
  68. Error running template: Error: trol
Add Comment
Please, Sign In to add comment