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>)
}
复制代码
后正常