Add unstable_strictModeLevel to test renderer (#20914)

Matches what we do for React DOM
This commit is contained in:
Andrew Clark
2021-03-02 10:41:57 -08:00
committed by GitHub
parent d857f9e4d0
commit de0ee76dbd
+6 -1
View File
@@ -56,6 +56,7 @@ const {IsSomeRendererActing} = ReactSharedInternals;
type TestRendererOptions = {
createNodeMock: (element: React$Element<any>) => any,
unstable_isConcurrent: boolean,
unstable_strictModeLevel: number,
...
};
@@ -433,6 +434,7 @@ function propsMatch(props: Object, filter: Object): boolean {
function create(element: React$Element<any>, options: TestRendererOptions) {
let createNodeMock = defaultTestOptions.createNodeMock;
let isConcurrent = false;
let strictModeLevel = null;
if (typeof options === 'object' && options !== null) {
if (typeof options.createNodeMock === 'function') {
createNodeMock = options.createNodeMock;
@@ -440,6 +442,9 @@ function create(element: React$Element<any>, options: TestRendererOptions) {
if (options.unstable_isConcurrent === true) {
isConcurrent = true;
}
if (options.unstable_strictModeLevel !== undefined) {
strictModeLevel = options.unstable_strictModeLevel;
}
}
let container = {
children: [],
@@ -451,7 +456,7 @@ function create(element: React$Element<any>, options: TestRendererOptions) {
isConcurrent ? ConcurrentRoot : LegacyRoot,
false,
null,
null,
strictModeLevel,
);
invariant(root != null, 'something went wrong');
updateContainer(element, root, null, null);