Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Component | ErrorBoundary #311

Open
aVileBroker opened this issue Aug 30, 2021 · 1 comment
Open

New Component | ErrorBoundary #311

aVileBroker opened this issue Aug 30, 2021 · 1 comment
Labels
0.5 Story Points issue size: .5 good first issue Good for newcomers help wanted Extra attention is needed new component New base component

Comments

@aVileBroker
Copy link
Contributor

Create an Error Boundary component which renders a default fallback UI which shows the error in a user-friendly way.

Props API:

  • children: ReactNode
  • fallbackUI (default to something simple and clean, no Card, etc)
  • onError function

One thing to consider is how we can use the global analytics function from the context provider to wrap the onError function. (Error boundaries are all class components)
https://reactjs.org/docs/context.html

Here is a decent start:

import { Component } from "react";

class ErrorBoundary extends Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false };
  }

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

  componentDidCatch(error, errorInfo) {
    if (this.props.onError) {
      this.props.onError(error, errorInfo);
    }
  }

  render() {
    if (this.state.hasError) {
      return this.props.fallbackUI;
    }

    return this.props.children;
  }
}

export default ErrorBoundary;
@aVileBroker aVileBroker added good first issue Good for newcomers help wanted Extra attention is needed new component New base component labels Aug 30, 2021
@aVileBroker aVileBroker added this to Backlog in Foundry-react-UI via automation Aug 30, 2021
@aVileBroker aVileBroker moved this from Backlog to Priority to do in Foundry-react-UI Aug 30, 2021
@masonwoodford
Copy link

Are you looking for people to help out with this?

@aVileBroker aVileBroker added the 0.5 Story Points issue size: .5 label Sep 8, 2021
@breanna-eubanks breanna-eubanks moved this from Priority to do to In progress in Foundry-react-UI Dec 22, 2021
@breanna-eubanks breanna-eubanks moved this from In progress to Priority to do in Foundry-react-UI Dec 22, 2021
@breanna-eubanks breanna-eubanks moved this from Priority to do to In progress in Foundry-react-UI Dec 22, 2021
@breanna-eubanks breanna-eubanks moved this from In progress to Priority to do in Foundry-react-UI Dec 23, 2021
@cnkeats cnkeats self-assigned this Apr 8, 2022
@aVileBroker aVileBroker reopened this Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.5 Story Points issue size: .5 good first issue Good for newcomers help wanted Extra attention is needed new component New base component
Projects
Status: Done
Foundry-react-UI
  
Priority to do
Development

No branches or pull requests

4 participants