mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Adds `flow` (or `noflow`) to all files in this directory and ensures that Flow succeeds (by adding type annotations, using minor refactors, or suppressing errors due to intentionally dynamic logic). This will help improve type safety when making changes both in these files as well as files that these depend on. Changelog: [Internal] Pull Request resolved: https://github.com/facebook/react-native/pull/51652 Test Plan: Ran Flow and Jest tests successfully: ``` $ yarn flow $ yarn test ``` Ran a Jest unit test internally to make sure they work with our internal environment setup: ``` $ cd ~/fbsource $ js1 test /View-test.js ``` Reviewed By: javache Differential Revision: D75488160 Pulled By: yungsters fbshipit-source-id: 536cef9699acfa1edcd3dcf61c53ebcd92f560f9
41 lines
963 B
JavaScript
41 lines
963 B
JavaScript
/**
|
|
* 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 type {ReactTestRenderer} from 'react-test-renderer';
|
|
|
|
import nullthrows from 'nullthrows';
|
|
import * as React from 'react';
|
|
import TestRenderer from 'react-test-renderer';
|
|
|
|
export async function create(
|
|
Component: React.MixedElement,
|
|
): Promise<ReactTestRenderer> {
|
|
let component;
|
|
await TestRenderer.act(async () => {
|
|
component = TestRenderer.create(Component);
|
|
});
|
|
return nullthrows(component);
|
|
}
|
|
|
|
export async function unmount(testRenderer: ReactTestRenderer) {
|
|
await TestRenderer.act(async () => {
|
|
testRenderer.unmount();
|
|
});
|
|
}
|
|
|
|
export async function update(
|
|
testRenderer: ReactTestRenderer,
|
|
element: React.MixedElement,
|
|
) {
|
|
await TestRenderer.act(async () => {
|
|
testRenderer.update(element);
|
|
});
|
|
}
|