/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/Libraries/Image/__tests__/Image-benchmark-itest.js
81 строка
2 KB
Ruslan Shestopalyuk
Don't populate default Image prop values on JS side (Android only) (#53225)
14 авг 2025, 17:55
14 авг 2025, 17:55
d2df64d
Код
Авторство
О чём код?
/** * 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 * @fantom_flags reduceDefaultPropsInImage:* */ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; import * as Fantom from '@react-native/fantom'; import * as React from 'react'; import {Image} from 'react-native'; const IMAGE1 = require('./img/img1.png'); const IMAGE2 = require('./img/img2.png'); let root; let testElements: React.MixedElement; Fantom.unstable_benchmark .suite('Image') .test.each( [100, 1000], n => `render ${n.toString()} images with no explicit props`, () => { Fantom.runTask(() => root.render(testElements)); }, n => ({ beforeAll: () => { testElements = ( <> {[...Array(n).keys()].map(i => ( <Image /> ))} </> ); }, beforeEach: () => { root = Fantom.createRoot(); }, afterEach: () => { root.destroy(); }, }), ) .test.each( [100, 1000], n => `render ${n.toString()} images`, () => { Fantom.runTask(() => root.render(testElements)); }, n => ({ beforeAll: () => { testElements = ( <> {Array.from({length: n}, (_, i) => ( <Image id={String(i)} nativeID={String(i)} source={i % 2 === 0 ? IMAGE1 : IMAGE2} style={{ width: i + 1, height: i + 1, }} /> ))} </> ); }, beforeEach: () => { root = Fantom.createRoot(); }, afterEach: () => { root.destroy(); }, }), );