/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/src/private/__tests__/utilities/ShadowNodeRevisionGetter.js
49 строк
1 KB
Samuel Susla
introduce a way to inspect shadow node revision in Fantom (#51566)
25 май 2025, 01:44
25 май 2025, 01:44
afb5436
Код
Авторство
О чём код?
/** * 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-local * @format */ import ReactNativeElement from '../../webapis/dom/nodes/ReadOnlyNode'; import ensureInstance from './ensureInstance'; import * as Fantom from '@react-native/fantom'; function createShadowNodeRevisionGetter( element: ReactNativeElement, ): () => ?number { const getRevision = Fantom.createShadowNodeRevisionGetter(element); return () => { return getRevision(); }; } export function createShadowNodeReferenceGetterRef(): [ () => ?number, React.RefSetter<mixed>, ] { let getRevision: ?() => ?number; function getShadowNodeReferenceCount() { if (getRevision == null) { throw new Error('ShadowNode revision getter was not initialized.'); } return getRevision(); } function ref(instance: mixed | null) { if (instance == null) { return; } const element = ensureInstance(instance, ReactNativeElement); if (getRevision != null) { throw new Error('ShadowNode revision getter was already initialized.'); } getRevision = createShadowNodeRevisionGetter(element); } return [getShadowNodeReferenceCount, ref]; }