如何在ESLint中避免此错误?我应该以不同的方式编写此代码吗?我无法更改ESLint配置,我应该有0个错误......
import React from 'react';
import logo from './logo.svg';
import './style.css';
import SearchBar from '../SearchBar';
import GithubDataTable from '../GithubDataTable';
const App = props => (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">The Task</h1>
</header>
<div>
<SearchBar />
<GithubDataTable />
</div>
</div>
);
export default App;
答案 0 :(得分:8)
根本不需要props
。
你可以把它写成没有参数的函数:
import React from 'react';
import logo from './logo.svg';
import './style.css';
import SearchBar from '../SearchBar';
import GithubDataTable from '../GithubDataTable';
const App = () => (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">The Task</h1>
</header>
<div>
<SearchBar />
<GithubDataTable />
</div>
</div>
);
export default App;