(fiber, errorInfo, lane)
| 18751 | } |
| 18752 | |
| 18753 | function createClassErrorUpdate(fiber, errorInfo, lane) { |
| 18754 | var update = createUpdate(NoTimestamp, lane); |
| 18755 | update.tag = CaptureUpdate; |
| 18756 | var getDerivedStateFromError = fiber.type.getDerivedStateFromError; |
| 18757 | |
| 18758 | if (typeof getDerivedStateFromError === 'function') { |
| 18759 | var error$1 = errorInfo.value; |
| 18760 | |
| 18761 | update.payload = function () { |
| 18762 | return getDerivedStateFromError(error$1); |
| 18763 | }; |
| 18764 | |
| 18765 | update.callback = function () { |
| 18766 | { |
| 18767 | markFailedErrorBoundaryForHotReloading(fiber); |
| 18768 | } |
| 18769 | |
| 18770 | logCapturedError(fiber, errorInfo); |
| 18771 | }; |
| 18772 | } |
| 18773 | |
| 18774 | var inst = fiber.stateNode; |
| 18775 | |
| 18776 | if (inst !== null && typeof inst.componentDidCatch === 'function') { |
| 18777 | update.callback = function callback() { |
| 18778 | { |
| 18779 | markFailedErrorBoundaryForHotReloading(fiber); |
| 18780 | } |
| 18781 | |
| 18782 | logCapturedError(fiber, errorInfo); |
| 18783 | |
| 18784 | if (typeof getDerivedStateFromError !== 'function') { |
| 18785 | // To preserve the preexisting retry behavior of error boundaries, |
| 18786 | // we keep track of which ones already failed during this batch. |
| 18787 | // This gets reset before we yield back to the browser. |
| 18788 | // TODO: Warn in strict mode if getDerivedStateFromError is |
| 18789 | // not defined. |
| 18790 | markLegacyErrorBoundaryAsFailed(this); |
| 18791 | } |
| 18792 | |
| 18793 | var error$1 = errorInfo.value; |
| 18794 | var stack = errorInfo.stack; |
| 18795 | this.componentDidCatch(error$1, { |
| 18796 | componentStack: stack !== null ? stack : '' |
| 18797 | }); |
| 18798 | |
| 18799 | { |
| 18800 | if (typeof getDerivedStateFromError !== 'function') { |
| 18801 | // If componentDidCatch is the only error boundary method defined, |
| 18802 | // then it needs to call setState to recover from errors. |
| 18803 | // If no state update is scheduled then the boundary will swallow the error. |
| 18804 | if (!includesSomeLane(fiber.lanes, SyncLane)) { |
| 18805 | error('%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentNameFromFiber(fiber) || 'Unknown'); |
| 18806 | } |
| 18807 | } |
| 18808 | } |
| 18809 | }; |
| 18810 | } |
no test coverage detected
searching dependent graphs…