Clarify error when passing class to render()
Ben Alpert committed
Jan 18, 2016 at 17:13 UTC
895fab782bc565bc1b8de434e00e1d50bd291279
2 files changed
+7
-9
src/renderers/dom/client/ReactMount.js
+4
-4
@@ -382,11 +382,11 @@ var ReactMount = {
382
'ReactDOM.render(): Invalid component element.%s',
383
(
384
typeof nextElement === 'string' ?
385
- ' Instead of passing an element string, make sure to instantiate ' +
386
- 'it by passing it to React.createElement.' :
385
+ ' Instead of passing a string like \'div\', pass ' +
386
+ 'React.createElement(\'div\') or <div />.' :
387
typeof nextElement === 'function' ?
388
- ' Instead of passing a component class, make sure to instantiate ' +
389
- 'it by passing it to React.createElement.' :
388
+ ' Instead of passing a class like Foo, pass ' +
389
+ 'React.createElement(Foo) or <Foo />.' :
390
// Check if it quacks like an element
391
nextElement != null && nextElement.props !== undefined ?
392
' This may be caused by unintentionally loading two independent ' +
src/renderers/dom/client/__tests__/ReactMount-test.js
+3
-5
@@ -54,9 +54,8 @@ describe('ReactMount', function() {
54
expect(function() {
55
ReactTestUtils.renderIntoDocument('div');
56
}).toThrow(
57
- 'ReactDOM.render(): Invalid component element. Instead of passing an ' +
58
- 'element string, make sure to instantiate it by passing it to ' +
59
- 'React.createElement.'
57
+ 'ReactDOM.render(): Invalid component element. Instead of passing a ' +
58
+ 'string like \'div\', pass React.createElement(\'div\') or <div />.'
59
);
60
});
61
@@ -70,8 +69,7 @@ describe('ReactMount', function() {
69
ReactTestUtils.renderIntoDocument(Component);
70
}).toThrow(
71
'ReactDOM.render(): Invalid component element. Instead of passing a ' +
73
- 'component class, make sure to instantiate it by passing it to ' +
74
- 'React.createElement.'
72
+ 'class like Foo, pass React.createElement(Foo) or <Foo />.'
73
);
74
});
75