Skip to content

Commit

Permalink
feat: ErrorBoundary added
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumeetrana committed Jan 7, 2021
1 parent f563814 commit 1946f59
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,47 @@ import React from "react";
import ReactDOM from "react-dom";
import { ApolloProvider } from "@apollo/react-hooks";
import { BrowserRouter as Router } from "react-router-dom";
import { MuiThemeProvider, CssBaseline } from "@material-ui/core";
import { MuiThemeProvider, CssBaseline, Typography } from "@material-ui/core";
import theme from "./theme";
import App from "./App";
import AuthProvider from "./auth";
import client from "./graphql/client";

class ErrorBoundary extends React.Component {
state = { hasError: false };

static getDerivedStateFromError() {
return { hasError: true };
}

componentDidCatch(error, info) {
console.error(error, info);
}

render() {
if (this.state.hasError) {
return (
<Typography component="h1" variant="h6" align="center">
Oops! Something went wrong
</Typography>
);
}
return this.props.children;
}
}

ReactDOM.render(
<ApolloProvider client={client}>
<AuthProvider>
<MuiThemeProvider theme={theme}>
<CssBaseline />
<Router>
<App />
</Router>
</MuiThemeProvider>
</AuthProvider>
</ApolloProvider>,
<ErrorBoundary>
<ApolloProvider client={client}>
<AuthProvider>
<MuiThemeProvider theme={theme}>
<CssBaseline />
<Router>
<App />
</Router>
</MuiThemeProvider>
</AuthProvider>
</ApolloProvider>
</ErrorBoundary>,
document.getElementById("root")
);

1 comment on commit 1946f59

@vercel
Copy link

@vercel vercel bot commented on 1946f59 Jan 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to assign a domain to your deployment due to the following error:

The chosen alias "reactagram.now.sh" is already in use.

Please sign in to comment.