From bb5a589d8b9163db74c605ef9d7a1b89ab5ecaf9 Mon Sep 17 00:00:00 2001 From: Inomdzhon Mirdzhamolov Date: Thu, 2 Nov 2023 13:32:18 +0300 Subject: [PATCH 1/2] fix(AppRoot): fix useInsets predicate for disable --- packages/vkui/src/components/AppRoot/AppRoot.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vkui/src/components/AppRoot/AppRoot.tsx b/packages/vkui/src/components/AppRoot/AppRoot.tsx index 1aae45d73d..1b996ada90 100644 --- a/packages/vkui/src/components/AppRoot/AppRoot.tsx +++ b/packages/vkui/src/components/AppRoot/AppRoot.tsx @@ -107,7 +107,8 @@ export const AppRoot = ({ const rootRef = React.useRef(null); const [portalRoot, setPortalRoot] = React.useState(null); const { document } = useDOM(); - const deprecatedInsets = useInsets(!safeAreaInsets); + const deprecatedInsetsDisabled = Boolean(safeAreaInsets); + const deprecatedInsets = useInsets(deprecatedInsetsDisabled); const insets = safeAreaInsets ? safeAreaInsets : deprecatedInsets; const appearance = useAppearance(); From c3ac649b0f28c4c76dcf3d0fcda3d3e669aa1845 Mon Sep 17 00:00:00 2001 From: Inomdzhon Mirdzhamolov Date: Thu, 2 Nov 2023 13:42:44 +0300 Subject: [PATCH 2/2] fix: deprecate withInsets --- packages/vkui/src/hoc/withInsets.tsx | 12 ++++++++++++ styleguide/pages/migration_v6.md | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/packages/vkui/src/hoc/withInsets.tsx b/packages/vkui/src/hoc/withInsets.tsx index 46c2607b49..50572cf0bc 100644 --- a/packages/vkui/src/hoc/withInsets.tsx +++ b/packages/vkui/src/hoc/withInsets.tsx @@ -1,10 +1,22 @@ import * as React from 'react'; import { useInsets } from '../hooks/useInsets'; +import { warnOnce } from '../lib/warnOnce'; import { HasInsets } from '../types'; +const warn = warnOnce('withInsets'); + +/** + * TODO [>=6]: удалить HOC (#5049) + * + * @deprecated v5.10.0 + */ export function withInsets( Component: React.ComponentType, ): React.ComponentType> { + if (process.env.NODE_ENV === 'development') { + warn("[@vkontakte/vk-bridge] Интеграция VKUI с @vkontakte/vk-bridge устарела и будет удалена в v6. Используйте хук `useInsets()` из @vkontakte/vk-bridge-react, для получения инсетов (см. https://github.com/VKCOM/VKUI/issues/5049)"); // prettier-ignore + } + function WithInsets(props: Omit) { const insets = useInsets(); return ; diff --git a/styleguide/pages/migration_v6.md b/styleguide/pages/migration_v6.md index 7ae59a6f34..854a9e436d 100644 --- a/styleguide/pages/migration_v6.md +++ b/styleguide/pages/migration_v6.md @@ -53,6 +53,10 @@ - `webviewType={WebviewType.INTERNAL}` -> `hasCustomPanelHeaderAfter={false}`. - `webviewType={WebviewType.VKAPPS}` -> `hasCustomPanelHeaderAfter={true}`. При необходимости передайте `customPanelHeaderAfterMinWidth={}` (по умолчанию `90`). +## ~`withInsets`~ + +Используйте вместо него хук `useInsets()` из [@vkontakte/vk-bridge-react](https://www.npmjs.com/package/@vkontakte/vk-bridge-react). + ## Поддержка браузеров Библиотека по умолчанию компилируется в [ES2015 (ES6)](https://262.ecma-international.org/6.0/).