問題:
I am using ReactJS.我正在使用 ReactJS。
When I run the code below the browser says:當我運行瀏覽器下面的代碼時,它說:
Uncaught TypeError: Super expression must either be null or a function, not undefined未捕獲的類型錯誤:超級表達式必須爲空或函數,而不是未定義
Any hints at all as to what is wrong would be appreciated.任何關於錯誤的提示都將不勝感激。
First the line used to compile the code:首先是用於編譯代碼的行:
browserify -t reactify -t babelify examples/temp.jsx -o examples/public/app.js
And the code:和代碼:
var React = require('react');
class HelloMessage extends React.Component {
render() {
return <div>Hello </div>;
}
}
UPDATE: After burning in hellfire for three days on this problem I found that I was not using the latest version of react.更新:在這個問題上在地獄火中燃燒了三天後,我發現我沒有使用最新版本的 react。
Install globally:全局安裝:
sudo npm install -g [email protected]
install locally:本地安裝:
npm install [email protected]
make sure the browser is using the right version too:確保瀏覽器也使用正確的版本:
<script type="text/javascript" src="react-0.13.2.js"></script>
Hope this saves someone else three days of precious life.希望這能挽救別人三天寶貴的生命。
解決方案:
參考一: https://en.stackoom.com/question/22Mes參考二: https://stackoom.com/question/22Mes