由於缺乏對Commonjs模塊的支持,從react_rails gem中感到沮喪之後,我正在從netguru測試react_webpack_rails gem。但從那以後我得到了一個不變的違規。React.js未捕獲錯誤:不變違規
例如,如果我正在寫在ES6語法簡單的Hello World組件:
import React from 'react';
class tasksBox extends React.Component {
render() {
return <div>Hello World</div>;
}
}
export default tasksBox;
提高這些錯誤:
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
您的幫助將非常感激,我不能圖中錯誤來自哪裏。
沒有錯的代碼中有這樣的問題是其他 –
您究竟如何渲染'tasksBox'? –
如果更改大小寫確實解決了問題,那麼您的實際代碼必須不同。 –