[英]get React' must be in scope when using JSX error when import component
I am writing this code and import React
and Component
in app/js
file and also try to import app.js to index.js
.我正在编写此代码并在
app/js
文件中导入React
和Component
,并尝试将 app.js 导入index.js
。 but I get this error
' 'React' must be in scope when using JSX
in index.js
但我收到此
error
“在index.js
使用JSX
时必须在范围内”
app.js :应用程序.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;
index.js索引.js
import ReactDOM from 'react-dom';
import App from './app'
ReactDOM.render(<App/>,document.getElementById('root'));
I got this error我收到这个错误
./src/index.js Line 6:'React' must be in scope when using JSX react/react-in-jsx-scope
./src/index.js 第 6 行:使用 JSX react/react-in-jsx-scope 时,'React' 必须在作用域内
You are using JSX in here ( <App />
):您在这里使用 JSX (
<App />
):
ReactDOM.render(<App/>,document.getElementById('root'));
Whenever you use JSX React should be in scope.每当您使用 JSX 时,React 都应该在范围内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.