/
githubmirror
/
ionic
Обзор
Документация
Войти
/
githubmirror
/
ionic
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/react/src/components/utils/index.tsx
56 строк
2 KB
Shane
fix(react): remove relocated inline overlays orphaned on unmount (#31223)
17 июн 2026, 20:19
Не верифицирован
17 июн 2026, 20:19
d28d25b
Код
Авторство
О чём код?
import type { Config as CoreConfig, Platforms } from '@ionic/core/components'; import { getPlatforms as getPlatformsCore, isPlatform as isPlatformCore } from '@ionic/core/components'; import React from 'react'; import type { IonicReactProps } from '../IonicReactProps'; export type IonicReactExternalProps<PropType, ElementType> = PropType & /** * TODO: FW-5753 * * The `placeholder` property was removed from `HTMLAttributes` in @types/react@18.2.43 * https://github.com/DefinitelyTyped/DefinitelyTyped/commit/b954269038de46b4b2f1756a9f2f020cbc66a326 * * This is a temporary workaround until @ionic/react is updated to >=18.2.43. */ Omit<React.HTMLAttributes<ElementType>, 'style' | 'placeholder'> & IonicReactProps; export const createForwardRef = <PropType, ElementType>( ReactComponent: any, // TODO(FW-2959): type displayName: string ) => { const forwardRef = (props: IonicReactExternalProps<PropType, ElementType>, ref: React.ForwardedRef<ElementType>) => { return <ReactComponent {...props} forwardedRef={ref} />; }; forwardRef.displayName = displayName; // Cast the render function to the type React.forwardRef already infers for it. // React 18's `forwardRef` wraps the props in `PropsWithoutRef`, and since // `PropType` is unconstrained TypeScript can't prove the round-trip is safe. // The cast keeps the inferred component type intact without widening to `any`. return React.forwardRef( forwardRef as React.ForwardRefRenderFunction< ElementType, React.PropsWithoutRef<IonicReactExternalProps<PropType, ElementType>> > ); }; export const isPlatform = (platform: Platforms) => { return isPlatformCore(window, platform); }; export const getPlatforms = () => { return getPlatformsCore(window); }; export const getConfig = (): CoreConfig | null => { if (typeof (window as any) !== 'undefined') { const Ionic = (window as any).Ionic; if (Ionic && Ionic.config) { return Ionic.config; } } return null; };