Skip to content

Commit 48c7b53

Browse files
author
Nicole Levy
committed
use invariant
1 parent 33d1edf commit 48c7b53

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/react/src/ReactElement.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import ReactCurrentOwner from './ReactCurrentOwner';
1212

1313
const hasOwnProperty = Object.prototype.hasOwnProperty;
1414

15+
const invariant = require('fbjs/lib/invariant');
16+
1517
const RESERVED_PROPS = {
1618
key: true,
1719
ref: true,
@@ -290,10 +292,10 @@ export function cloneAndReplaceKey(oldElement, newKey) {
290292
* See https://reactjs.org/docs/react-api.html#cloneelement
291293
*/
292294
export function cloneElement(element, config, children) {
293-
294-
if (!element) {
295-
throw new TypeError('Cannot clone null or undefined.');
296-
}
295+
invariant(
296+
!(element === null || element === undefined),
297+
'Cannot clone a null or undefined element.'
298+
);
297299

298300
let propName;
299301

0 commit comments

Comments
 (0)