mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Wrap jest/renderer create abstraction in act for concurrent rendering (#44994)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44994 For RN monorepo tests, wrap `create` calls through our `jest/renderer` abstraction in `await act`. This is a no-op under current React but will be required under `react-test-renderer@19` with `IS_REACT_ACT_ENVIRONMENT`. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D58650940 fbshipit-source-id: 4013af89dd7c9f447b2dd493989f3a4fdf2b6508
This commit is contained in:
committed by
Facebook GitHub Bot
parent
84866617de
commit
132e2a305c
+5
@@ -101,6 +101,11 @@ exports[`LogBoxInspectorSourceMapStatus should render for pending 1`] = `
|
||||
"height": 14,
|
||||
"marginEnd": 4,
|
||||
"tintColor": "rgba(250, 186, 48, 1)",
|
||||
"transform": Array [
|
||||
Object {
|
||||
"rotate": "0deg",
|
||||
},
|
||||
],
|
||||
"width": 16,
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -11,11 +11,16 @@
|
||||
|
||||
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.Element<any>,
|
||||
): Promise<ReactTestRenderer> {
|
||||
return TestRenderer.create(Component);
|
||||
let component;
|
||||
await TestRenderer.act(async () => {
|
||||
component = TestRenderer.create(Component);
|
||||
});
|
||||
return nullthrows(component);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user