From e90c0e4b741500d43554b5631e71111588a2c57c Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 2 Mar 2021 12:35:37 -0600 Subject: [PATCH] Add unstable_strictModeLevel to test renderer Matches what we do for React DOM --- packages/react-test-renderer/src/ReactTestRenderer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-test-renderer/src/ReactTestRenderer.js b/packages/react-test-renderer/src/ReactTestRenderer.js index ff80440379f14..65da95aad5bfa 100644 --- a/packages/react-test-renderer/src/ReactTestRenderer.js +++ b/packages/react-test-renderer/src/ReactTestRenderer.js @@ -56,6 +56,7 @@ const {IsSomeRendererActing} = ReactSharedInternals; type TestRendererOptions = { createNodeMock: (element: React$Element) => any, unstable_isConcurrent: boolean, + unstable_strictModeLevel: number, ... }; @@ -433,6 +434,7 @@ function propsMatch(props: Object, filter: Object): boolean { function create(element: React$Element, 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, 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, options: TestRendererOptions) { isConcurrent ? ConcurrentRoot : LegacyRoot, false, null, - null, + strictModeLevel, ); invariant(root != null, 'something went wrong'); updateContainer(element, root, null, null);