Skip to content

Commit

Permalink
Moved shallow renderer injections into render() method to avoid confl…
Browse files Browse the repository at this point in the history
…ict with react-dom
  • Loading branch information
Brian Vaughn committed Apr 6, 2017
1 parent 72531d3 commit 714e5ea
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/renderers/testing/ReactShallowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 714e5ea

Please sign in to comment.