Guest User

Untitled

a guest
Dec 12th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import React from 'react';
  2.  
  3. class GlobalErrorBoundary extends React.Component {
  4. constructor(props) {
  5. super(props);
  6. this.state = { hasError: false };
  7. }
  8.  
  9. static getDerivedStateFromError(error) {
  10. return { hasError: true };
  11. }
  12.  
  13. componentDidCatch(error, info) {
  14. // Customized error handling goes here!
  15. }
  16.  
  17. render() {
  18. if (this.state.hasError) {
  19. return (
  20. <div>
  21. <h1>Meteorite Explorer encountered an error! Oh My!</h1>
  22. </div>
  23. );
  24. }
  25.  
  26. return this.props.children;
  27. }
  28. }
  29.  
  30. export default GlobalErrorBoundary;
Add Comment
Please, Sign In to add comment