Skip to content

Commit 8ae1364

Browse files
committed
Check if React.Fragment exists in invariant
1 parent 1f28090 commit 8ae1364

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

packages/react-router/modules/Router.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import invariant from "invariant";
33
import React from "react";
44
import PropTypes from "prop-types";
55

6-
function is16Plus() {
7-
const [major] = React.version.split('.');
8-
return parseInt(major) >= 16;
9-
}
10-
116
/**
127
* The public API for putting history on context.
138
*/
@@ -55,9 +50,11 @@ class Router extends React.Component {
5550
const { children, history } = this.props;
5651

5752
invariant(
58-
is16Plus() || children == null || React.Children.count(children) === 1,
59-
'A <Router> may have only one child element'
60-
)
53+
React.Fragment !== undefined ||
54+
children == null ||
55+
React.Children.count(children) === 1,
56+
"A <Router> may have only one child element"
57+
);
6158

6259
// Do this here so we can setState when a <Redirect> changes the
6360
// location in componentWillMount. This happens e.g. when doing
@@ -81,7 +78,7 @@ class Router extends React.Component {
8178
}
8279

8380
render() {
84-
return this.props.children || null
81+
return this.props.children || null;
8582
}
8683
}
8784

0 commit comments

Comments
 (0)