Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react js error boundary functional component

// https://gist.github.com/andywer/800f3f25ce3698e8f8b5f1e79fed5c9c
import Catch from "./functional-error-boundary"

type Props = {
  children: React.ReactNode
}

const MyErrorBoundary = Catch(function MyErrorBoundary(props: Props, error?: Error) {
  if (error) {
    return (
      <div className="error-screen">
        <h2>An error has occured</h2>
        <h4>{error.message}</h4>
      </div>
    )
  } else {
    return <React.Fragment>{props.children}</React.Fragment>
  }
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: cancel an event in javascript 
Javascript :: how to select a few properties from an object javascript 
Javascript :: How to blacklist words with discord.js 
Javascript :: create primary key in mongodb 
Javascript :: template literals javascript 
Javascript :: jest spyon 
Javascript :: using hooks with apis 
Javascript :: componentwillunmount hooks 
Javascript :: Run project in visual studio with iis express 
Javascript :: javascript replace ios apostrophe 
Javascript :: how to create a point in js 
Javascript :: foreach loop google script 
Javascript :: tailwind dynamic classes 
Javascript :: delete element from array js 
Javascript :: axios react js 
Javascript :: jquery fixed element on scroll footer 
Javascript :: https express 
Javascript :: get year javascript copyright 
Javascript :: submit form react js 
Javascript :: nodejs fs writefile base64url 
Javascript :: webpack url loader not working 
Javascript :: puppeteer 
Javascript :: how to replace div element with another in javascript 
Javascript :: this.setstate prevstate 
Javascript :: comment in js 
Javascript :: how to get property names from object using map method react 
Javascript :: how to get user info from google oauth node js 
Javascript :: smtp js 
Javascript :: how to delete object properties in javascript 
Javascript :: vuetify sass variables vue-cli 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =