/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/Libraries/ReactNative/getCachedComponentWithDebugName.js
33 строки
873 B
Sam Zhou
Replace most of the remaining `React.AbstractComponent` in react-native (#47143)
22 окт 2024, 01:48
22 окт 2024, 01:48
723a37c
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict * @format */ import * as React from 'react'; type NoopComponent = component(children: React.Node); const cache: Map< string, // displayName NoopComponent, // ComponentWithDisplayName > = new Map(); export default function getCachedComponentWithDisplayName( displayName: string, ): NoopComponent { let ComponentWithDisplayName = cache.get(displayName); if (!ComponentWithDisplayName) { ComponentWithDisplayName = ({children}: {children: React.Node}) => children; // $FlowFixMe[prop-missing] ComponentWithDisplayName.displayName = displayName; cache.set(displayName, ComponentWithDisplayName); } return ComponentWithDisplayName; }