ReactDOM
import React from 'react';
import App from './App';
React.ReactDOM.render(<App />, document.getElementById('root'));
複製程式碼
console報錯render找不到,這是因為react已經把ReactDOM分離出來,這樣引用會出錯,改為
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />, document.getElementById('root'));
複製程式碼
後正常
return 錯誤
console錯誤資訊
Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null
複製程式碼
這是因為程式碼中return同一行沒有程式碼
render(){
return
(
<div>
<p>App test</p>
</div>)
}
複製程式碼
改為
render(){
return (
<div>
<p>App test</p>
</div>)
}
複製程式碼
後正常