From de0ee76dbde0a5ec507cf4a62c9690f67b56d7b6 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 2 Mar 2021 12:41:57 -0600 Subject: [PATCH] Add unstable_strictModeLevel to test renderer (#20914) 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);