import React from 'react' ; import { Failed } from 'design/CardError' ; import Logger from 'shared/libs/logger' ; const logger = Logger . create ( 'components/CatchError' ) ; export default class CatchError extends React . Component { static getDerivedStateFromError ( error ) { return { error } ; } state = { error : null , } ; componentDidCatch ( err ) { logger . error ( 'render' , err ) ; } render ( ) { if ( this . state . error ) { return ( < Failed alignSelf = { 'baseline' } message = { this . state . error . message } / > ) ; } return this . props . children ; } }