英文:
'UserInput' is defined but never used no-unused-vars 'UserOutput' is defined but never used no-unused-vars
问题
以下是您要翻译的内容:
App.js
import React, { Component } 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>some random text</p>
<UserInput />
<UserOutput />
</div>
);
}
}
export default App;
UserInput.js
import React from 'react';
const userInput = () => {
return <input type="text" />;
};
export default userInput;
UserOutput.js
import React from 'react';
const userOutput = () => {
return (
<div>
<button>hello </button>
</div>
);
};
export default userOutput;
请注意,我已经将代码中的HTML标签进行了恢复,以便更好地阅读。如果您需要任何其他帮助,请随时提出。
英文:
newbie to react, following a series of lecture
*i just trying to excute this simple code but something went wrong and gave me error like 'UserInput' is defined but never used although path and src sets perfectly ok ***
App.js
import React, { Component } 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>some random text</p>
<userInput />
<userOutput />
</div>
);
}
}
export default App;
UserInput.js
import React from 'react';
const userInput = () => {
return <input type="text" />;
};
export default userInput;
UserOutput.js
import React from 'react';
const userOutput = () => {
return(<div>
<button>hello </button>
</div>)
};
export default userOutput;
答案1
得分: 0
改进
将class App extends Component{}
定义为class App extends Component() {}
将导入的UserInput
和UserOutput
定义如下:
<UserInput />
<UserOutput />
App.js
import UserInput from './UserInput/UserInput';
import UserOutput from './UserOutput/UserOutput';
class App extends Component {
render() {
return (
<div className="App">
<p>一些随机文本</p>
<UserInput />
<UserOutput />
</div>
);
}
}
export default App;
您的代码的在线演示 demo
英文:
Improvement
Define class App extends Component{}
not class App extends Component(){}
Define imported UserInput
,UserInput
like
<UserInput />
<UserOutput />
App.js
import UserInput from './UserInput/UserInput';
import UserOutput from './UserOutput/UserOutput';
class App extends Component{
render() {
return (
<div className="App">
<p>some random text</p>
<UserInput />
<UserOutput />
</div>
);
}}
export default App;
Live demo for your code demo
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论