From 0db5a0c5d96d290ded7e7b08a7ff45d537d5f95c Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Fri, 27 Dec 2024 03:58:12 +0900 Subject: [PATCH] Only warn when `as` is undefined --- .../src/navigator/navigator-back-button/hook.ts | 14 ++++++++------ .../src/navigator/navigator-button/hook.ts | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/components/src/navigator/navigator-back-button/hook.ts b/packages/components/src/navigator/navigator-back-button/hook.ts index 020428bb328cea..129742241a6036 100644 --- a/packages/components/src/navigator/navigator-back-button/hook.ts +++ b/packages/components/src/navigator/navigator-back-button/hook.ts @@ -34,12 +34,14 @@ export function useNavigatorBackButton( [ goBack, onClick ] ); - maybeWarnDeprecated36pxSize( { - componentName: 'Navigator.BackButton', - __next40pxDefaultSize: otherProps.__next40pxDefaultSize, - size: otherProps.size, - hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version. For icon buttons, consider setting a non-default size like `size: "compact"`.', - } ); + if ( as === undefined ) { + maybeWarnDeprecated36pxSize( { + componentName: 'Navigator.BackButton', + __next40pxDefaultSize: otherProps.__next40pxDefaultSize, + size: otherProps.size, + hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version. For icon buttons, consider setting a non-default size like `size: "compact"`.', + } ); + } return { as: as ?? Button, diff --git a/packages/components/src/navigator/navigator-button/hook.ts b/packages/components/src/navigator/navigator-button/hook.ts index 75d9fc7f9b51f4..5b9981e1f58aad 100644 --- a/packages/components/src/navigator/navigator-button/hook.ts +++ b/packages/components/src/navigator/navigator-button/hook.ts @@ -46,12 +46,14 @@ export function useNavigatorButton( [ goTo, onClick, attributeName, escapedPath ] ); - maybeWarnDeprecated36pxSize( { - componentName: 'Navigator.Button', - __next40pxDefaultSize: otherProps.__next40pxDefaultSize, - size: otherProps.size, - hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version. For icon buttons, consider setting a non-default size like `size: "compact"`.', - } ); + if ( as === undefined ) { + maybeWarnDeprecated36pxSize( { + componentName: 'Navigator.Button', + __next40pxDefaultSize: otherProps.__next40pxDefaultSize, + size: otherProps.size, + hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version. For icon buttons, consider setting a non-default size like `size: "compact"`.', + } ); + } return { as: as ?? Button,