Skip to content

Commit

Permalink
Add unstable_strictModeLevel to test renderer (#20914)
Browse files Browse the repository at this point in the history
Matches what we do for React DOM
  • Loading branch information
acdlite authored Mar 2, 2021
1 parent d857f9e commit de0ee76
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react-test-renderer/src/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const {IsSomeRendererActing} = ReactSharedInternals;
type TestRendererOptions = {
createNodeMock: (element: React$Element<any>) => any,
unstable_isConcurrent: boolean,
unstable_strictModeLevel: number,
...
};

Expand Down Expand Up @@ -433,13 +434,17 @@ 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;
}
if (options.unstable_isConcurrent === true) {
isConcurrent = true;
}
if (options.unstable_strictModeLevel !== undefined) {
strictModeLevel = options.unstable_strictModeLevel;
}
}
let container = {
children: [],
Expand All @@ -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);
Expand Down

0 comments on commit de0ee76

Please sign in to comment.