From 714e5ea65e6a132276a8907bfbf1e1ffd151f8c5 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 6 Apr 2017 11:29:41 -0700 Subject: [PATCH] Moved shallow renderer injections into render() method to avoid conflict with react-dom --- src/renderers/testing/ReactShallowRenderer.js | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/renderers/testing/ReactShallowRenderer.js b/src/renderers/testing/ReactShallowRenderer.js index 32981e7129..7a64694fcd 100644 --- a/src/renderers/testing/ReactShallowRenderer.js +++ b/src/renderers/testing/ReactShallowRenderer.js @@ -22,14 +22,14 @@ var emptyObject = require('emptyObject'); var getNextDebugID = require('getNextDebugID'); var invariant = require('invariant'); -// Ensure we've done the default injections. -// This might not be true in the case of a simple test that only requires React + ReactShallowRenderer. -ReactUpdates.injection.injectReconcileTransaction( - ReactTestReconcileTransaction -); -ReactUpdates.injection.injectBatchingStrategy( - ReactDefaultBatchingStrategy -); +function injectDefaults() { + ReactUpdates.injection.injectReconcileTransaction( + ReactTestReconcileTransaction + ); + ReactUpdates.injection.injectBatchingStrategy( + ReactDefaultBatchingStrategy + ); +} class NoopInternalComponent { constructor(element) { @@ -89,6 +89,11 @@ class ReactShallowRenderer { return this._instance ? this._instance._instance : null; } render(element, context) { + // Ensure we've done the default injections. This might not be true in the + // case of a simple test that only requires React and the TestUtils in + // conjunction with an inline-requires transform. + injectDefaults(); + invariant( React.isValidElement(element), 'ReactShallowRenderer render(): Invalid component element.%s',