(fiber, errorInfo, lane)
| 18734 | } |
| 18735 | |
| 18736 | function createClassErrorUpdate(fiber, errorInfo, lane) { |
| 18737 | var update = createUpdate(NoTimestamp, lane); |
| 18738 | update.tag = CaptureUpdate; |
| 18739 | var getDerivedStateFromError = fiber.type.getDerivedStateFromError; |
| 18740 | |
| 18741 | if (typeof getDerivedStateFromError === 'function') { |
| 18742 | var error$1 = errorInfo.value; |
| 18743 | |
| 18744 | update.payload = function () { |
| 18745 | return getDerivedStateFromError(error$1); |
| 18746 | }; |
| 18747 | |
| 18748 | update.callback = function () { |
| 18749 | { |
| 18750 | markFailedErrorBoundaryForHotReloading(fiber); |
| 18751 | } |
| 18752 | |
| 18753 | logCapturedError(fiber, errorInfo); |
| 18754 | }; |
| 18755 | } |
| 18756 | |
| 18757 | var inst = fiber.stateNode; |
| 18758 | |
| 18759 | if (inst !== null && typeof inst.componentDidCatch === 'function') { |
| 18760 | update.callback = function callback() { |
| 18761 | { |
| 18762 | markFailedErrorBoundaryForHotReloading(fiber); |
| 18763 | } |
| 18764 | |
| 18765 | logCapturedError(fiber, errorInfo); |
| 18766 | |
| 18767 | if (typeof getDerivedStateFromError !== 'function') { |
| 18768 | // To preserve the preexisting retry behavior of error boundaries, |
| 18769 | // we keep track of which ones already failed during this batch. |
| 18770 | // This gets reset before we yield back to the browser. |
| 18771 | // TODO: Warn in strict mode if getDerivedStateFromError is |
| 18772 | // not defined. |
| 18773 | markLegacyErrorBoundaryAsFailed(this); |
| 18774 | } |
| 18775 | |
| 18776 | var error$1 = errorInfo.value; |
| 18777 | var stack = errorInfo.stack; |
| 18778 | this.componentDidCatch(error$1, { |
| 18779 | componentStack: stack !== null ? stack : '' |
| 18780 | }); |
| 18781 | |
| 18782 | { |
| 18783 | if (typeof getDerivedStateFromError !== 'function') { |
| 18784 | // If componentDidCatch is the only error boundary method defined, |
| 18785 | // then it needs to call setState to recover from errors. |
| 18786 | // If no state update is scheduled then the boundary will swallow the error. |
| 18787 | if (!includesSomeLane(fiber.lanes, SyncLane)) { |
| 18788 | 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'); |
| 18789 | } |
| 18790 | } |
| 18791 | } |
| 18792 | }; |
| 18793 | } |
no test coverage detected
searching dependent graphs…