Module 484030

1,424 characters · in 5a60aef4295006b6.js
Dependencies
Required by (2)
Lazily required by (0)none
Requires (1)
Lazily requires (0)none
Source Raw
function(e,t,r){r.d(t,{tH:()=>i});var s=r(64700);let o=(0,s.createContext)(null),n={didCatch:!1,error:null};class i extends s.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=n}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,r,s=arguments.length,o=Array(s),i=0;i<s;i++)o[i]=arguments[i];null==(t=(r=this.props).onReset)||t.call(r,{args:o,reason:"imperative-api"}),this.setState(n)}}componentDidCatch(e,t){var r,s;null==(r=(s=this.props).onError)||r.call(s,e,t)}componentDidUpdate(e,t){let{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,s)){var o,i;null==(o=(i=this.props).onReset)||o.call(i,{next:s,prev:e.resetKeys,reason:"keys"}),this.setState(n)}}render(){let{children:e,fallbackRender:t,FallbackComponent:r,fallback:n}=this.props,{didCatch:i,error:a}=this.state,l=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)l=t(e);else if(r)l=(0,s.createElement)(r,e);else if(void 0!==n)l=n;else throw a}return(0,s.createElement)(o.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},l)}}}