Commit 24b79b2b authored by devjiwonchoi's avatar devjiwonchoi

Rename error boundary retry callback to unstable_retry

parent 5e098bf2
...@@ -7,7 +7,7 @@ import { errorStyles, errorThemeCss, ErrorIcon } from './error-styles' ...@@ -7,7 +7,7 @@ import { errorStyles, errorThemeCss, ErrorIcon } from './error-styles'
export type GlobalErrorComponent = React.ComponentType<{ export type GlobalErrorComponent = React.ComponentType<{
error: any error: any
reset: () => void reset: () => void
retry: () => void unstable_retry: () => void
componentStack: React.ErrorInfo['componentStack'] componentStack: React.ErrorInfo['componentStack']
/** DEV-only */ /** DEV-only */
ownerStack: ReturnType<typeof React.captureOwnerStack> ownerStack: ReturnType<typeof React.captureOwnerStack>
......
...@@ -17,7 +17,7 @@ const isBotUserAgent = ...@@ -17,7 +17,7 @@ const isBotUserAgent =
export type ErrorComponent = React.ComponentType<{ export type ErrorComponent = React.ComponentType<{
error: Error error: Error
reset: () => void reset: () => void
retry: () => void unstable_retry: () => void
componentStack: React.ErrorInfo['componentStack'] componentStack: React.ErrorInfo['componentStack']
/** DEV-only */ /** DEV-only */
ownerStack: ReturnType<typeof React.captureOwnerStack> ownerStack: ReturnType<typeof React.captureOwnerStack>
...@@ -132,7 +132,7 @@ export class ErrorBoundaryHandler extends React.Component< ...@@ -132,7 +132,7 @@ export class ErrorBoundaryHandler extends React.Component<
}) })
} }
retry = () => { unstable_retry = () => {
startTransition(() => { startTransition(() => {
this.context?.refresh() this.context?.refresh()
this.reset() this.reset()
...@@ -152,7 +152,7 @@ export class ErrorBoundaryHandler extends React.Component< ...@@ -152,7 +152,7 @@ export class ErrorBoundaryHandler extends React.Component<
<this.props.errorComponent <this.props.errorComponent
error={this.state.error} error={this.state.error}
reset={this.reset} reset={this.reset}
retry={this.retry} unstable_retry={this.unstable_retry}
componentStack={this.state.componentStack} componentStack={this.state.componentStack}
ownerStack={this.state.ownerStack} ownerStack={this.state.ownerStack}
/> />
......
...@@ -26,14 +26,14 @@ function ErroredHtml({ ...@@ -26,14 +26,14 @@ function ErroredHtml({
globalError: [GlobalError, globalErrorStyles], globalError: [GlobalError, globalErrorStyles],
error, error,
reset, reset,
retry, unstable_retry,
componentStack, componentStack,
ownerStack, ownerStack,
}: { }: {
globalError: GlobalErrorState globalError: GlobalErrorState
error: unknown error: unknown
reset: () => void reset: () => void
retry: () => void unstable_retry: () => void
componentStack: React.ErrorInfo['componentStack'] componentStack: React.ErrorInfo['componentStack']
ownerStack: ReturnType<typeof React.captureOwnerStack> ownerStack: ReturnType<typeof React.captureOwnerStack>
}) { }) {
...@@ -51,7 +51,7 @@ function ErroredHtml({ ...@@ -51,7 +51,7 @@ function ErroredHtml({
<GlobalError <GlobalError
error={error} error={error}
reset={reset} reset={reset}
retry={retry} unstable_retry={unstable_retry}
componentStack={componentStack} componentStack={componentStack}
ownerStack={ownerStack} ownerStack={ownerStack}
/> />
...@@ -99,7 +99,7 @@ export class AppDevOverlayErrorBoundary extends PureComponent< ...@@ -99,7 +99,7 @@ export class AppDevOverlayErrorBoundary extends PureComponent<
dispatcher.openErrorOverlay() dispatcher.openErrorOverlay()
} }
retry = () => { unstable_retry = () => {
startTransition(() => { startTransition(() => {
this.context?.refresh() this.context?.refresh()
this.reset() this.reset()
...@@ -123,7 +123,7 @@ export class AppDevOverlayErrorBoundary extends PureComponent< ...@@ -123,7 +123,7 @@ export class AppDevOverlayErrorBoundary extends PureComponent<
globalError={globalError} globalError={globalError}
error={reactError} error={reactError}
reset={this.reset} reset={this.reset}
retry={this.retry} unstable_retry={this.unstable_retry}
componentStack={componentStack} componentStack={componentStack}
ownerStack={ownerStack} ownerStack={ownerStack}
/> />
......
...@@ -5,7 +5,7 @@ import styles from './style.module.css' ...@@ -5,7 +5,7 @@ import styles from './style.module.css'
export default function ErrorBoundary({ export default function ErrorBoundary({
error, error,
reset, reset,
retry, unstable_retry,
componentStack, componentStack,
ownerStack, ownerStack,
}) { }) {
...@@ -17,7 +17,11 @@ export default function ErrorBoundary({ ...@@ -17,7 +17,11 @@ export default function ErrorBoundary({
<button id="reset" onClick={() => reset()} className={styles.button}> <button id="reset" onClick={() => reset()} className={styles.button}>
Try again Try again
</button> </button>
<button id="retry" onClick={() => retry()} className={styles.button}> <button
id="retry"
onClick={() => unstable_retry()}
className={styles.button}
>
Retry Retry
</button> </button>
</> </>
......
'use client' 'use client'
export default function ErrorBoundary({ error, reset, retry }) { export default function ErrorBoundary({ error, reset, unstable_retry }) {
return ( return (
<> <>
<p id="error-boundary-message">{error.message}</p> <p id="error-boundary-message">{error.message}</p>
...@@ -8,7 +8,7 @@ export default function ErrorBoundary({ error, reset, retry }) { ...@@ -8,7 +8,7 @@ export default function ErrorBoundary({ error, reset, retry }) {
<button id="reset" onClick={() => reset()}> <button id="reset" onClick={() => reset()}>
Try again Try again
</button> </button>
<button id="retry" onClick={() => retry()}> <button id="retry" onClick={() => unstable_retry()}>
Retry Retry
</button> </button>
</> </>
......
...@@ -412,8 +412,8 @@ describe('app-dir - errors', () => { ...@@ -412,8 +412,8 @@ describe('app-dir - errors', () => {
}) })
} }
describe('retry', () => { describe('unstable_retry', () => {
it('should recover Server Component error after retry', async () => { it('should recover Server Component error after unstable_retry', async () => {
const browser = await next.browser('/server-component/recover') const browser = await next.browser('/server-component/recover')
expect( expect(
...@@ -432,7 +432,7 @@ describe('app-dir - errors', () => { ...@@ -432,7 +432,7 @@ describe('app-dir - errors', () => {
expect(await browser.elementByCss('#recover').text()).toBe('Recovered') expect(await browser.elementByCss('#recover').text()).toBe('Recovered')
}) })
it('should recover Client Component error after retry', async () => { it('should recover Client Component error after unstable_retry', async () => {
const browser = await next.browser('/client-component') const browser = await next.browser('/client-component')
// Try triggering and retrying a few times in a row // Try triggering and retrying a few times in a row
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment