[英]get React' must be in scope when using JSX error when import component
我正在編寫此代碼並在app/js
文件中導入React
和Component
,並嘗試將 app.js 導入index.js
。 但我收到此error
“在index.js
使用JSX
時必須在范圍內”
應用程序.js:
import React ,{Component} from 'react';
class App extends Component{
constructor(props){
super(props);
}
render(){
return (
<div>
<h1>Hello Ashkan</h1>
</div>
);
}
}
export default App;
索引.js
import ReactDOM from 'react-dom';
import App from './app'
ReactDOM.render(<App/>,document.getElementById('root'));
我收到這個錯誤
./src/index.js 第 6 行:使用 JSX react/react-in-jsx-scope 時,'React' 必須在作用域內
您在這里使用 JSX ( <App />
):
ReactDOM.render(<App/>,document.getElementById('root'));
每當您使用 JSX 時,React 都應該在范圍內。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.