Skip to content

Commit c65d6de

Browse files
authored
polish: warn deprecated beforeDestroy/destroyed lifecycle hooks (#1999)
1 parent fcf9b2c commit c65d6de

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/runtime-core/src/componentOptions.ts

+16
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,11 @@ interface LegacyOptions<
316316
updated?(): void
317317
activated?(): void
318318
deactivated?(): void
319+
/** @deprecated use `beforeUnmount` instead */
320+
beforeDestroy?(): void
319321
beforeUnmount?(): void
322+
/** @deprecated use `unmounted` instead */
323+
destroyed?(): void
320324
unmounted?(): void
321325
renderTracked?: DebuggerHook
322326
renderTriggered?: DebuggerHook
@@ -393,7 +397,9 @@ export function applyOptions(
393397
updated,
394398
activated,
395399
deactivated,
400+
beforeDestroy,
396401
beforeUnmount,
402+
destroyed,
397403
unmounted,
398404
render,
399405
renderTracked,
@@ -631,9 +637,19 @@ export function applyOptions(
631637
if (renderTriggered) {
632638
onRenderTriggered(renderTriggered.bind(publicThis))
633639
}
640+
if (__DEV__ && beforeDestroy) {
641+
warn(
642+
`\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`
643+
)
644+
}
634645
if (beforeUnmount) {
635646
onBeforeUnmount(beforeUnmount.bind(publicThis))
636647
}
648+
if (__DEV__ && destroyed) {
649+
warn(
650+
`\`destroyed\` has been renamed to \`unmounted\`.`
651+
)
652+
}
637653
if (unmounted) {
638654
onUnmounted(unmounted.bind(publicThis))
639655
}

0 commit comments

Comments
 (0)