Nerds-Who-Code / Mental-Health-Tracker

mental-health-tracker.vercel.app
MIT License
5 stars 6 forks source link

Add error boundary component #41

Closed steph-koopmanschap closed 1 year ago

steph-koopmanschap commented 2 years ago

Added the error boundary class component from https://reactjs.org/docs/error-boundaries.html

Haven't wrapped it around any components yet, but I might do so in the near future. This component will be helpful for debugging and preventing the entire app from crashing.

/* 
    This error boundery class component works similar to 
    a try - catch block in javascript.
    Wrap this component around another component like so

    <ErrorBoundary>
        <YourComponent />
    </ErrorBoundary>

    This will prevent the entire app from crashing if there is an error in the <YourComponent />
    However the <YourComponent /> will no longer render and instead the render function of this component will render instead.
*/