[英]'Component' is not defined no-undef Search for the keywords to learn more about each error
App.js应用程序.js
import React from 'react';
import './App.css';
import UserInput from './USerInput/UserInput';
import UserOutput from './UserOutput/UserOutput';
class App extends Component {
render() {
return (
<div className="App">
<p>Somekind of text </p>
<userInput />
<userOutput />
</div>
);
}
}
export default App;
UserInput.js用户输入.js
import React from 'react';
import './App.css';
const userInput = () => {
return <input type="text" />
};
export default userInput;
Output.js输出.js
import React from 'react';
import './App.css';
const userOutput = () => {
return <input type="text" />
};
export default userOutput;
Error is in * USerOutput.js * could not be properly linked with src as it dims code line in VSCode too and the below component error错误在 * USerOutput.js * 无法与 src 正确链接,因为它也会使 VSCode 中的代码行变暗,并且出现以下组件错误
./src/App.js
Line 10:19: 'Component' is not defined no-undef
Search for the keywords to learn more about each error.
*'Component' is not defined no-undef Search for the keywords to learn more about each error and previously * this ** Module not found: Can't resolve './App.css' in 'C:\\Users\\hp\\Desktop\\Reactjs\\exercise\\src\\User Output'** *'Component' 未定义 no-undef 搜索关键字以了解有关每个错误和以前的更多信息 * 此 ** 找不到模块:无法解析 'C:\\Users\\hp\\ 中的 './App.css'桌面\\Reactjs\\exercise\\src\\用户输出'**
Because of the line of class App extends Component
in App.js you need to import Component
also.由于App.js 中的
class App extends Component
这一行,您还需要导入Component
。
Just like the following:就像下面这样:
import React, { Component } from 'react';
I hope this helps!我希望这有帮助!
import React, { Component } from 'react'; import React, { Component } from 'react';
import this package in top.在顶部导入这个包。 And I hope it'll work
我希望它会奏效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.