简体   繁体   English

与模块订单有关的EsLint问题

[英]EsLint issue related to module order

I got errors 我有错误

Line 18: Import in body of module; 第18行:导入模块主体; reorder to top import/first 重新排序到顶部导入/第一

Line 19: Import in body of module; 第19行:导入模块主体; reorder to top import/first 重新排序到顶部导入/第一

Searching answer, as I understood this problem is related to order of imported modules, but I'm begginer, please help me to clearify, what exactly I should do with my code, because I tried to reorder, but nothing happend. 搜索答案,据我所知,这个问题与导入模块的顺序有关,但是我是乞gg,请帮我弄清楚我应该对我的代码执行什么操作,因为我尝试重新排序,但是什么也没发生。

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

// Import Components
import Main from './components/Main';
import Single from './components/Single';
import PhotoGrid from './components/PhotoGrid';


// Import react router deps
import { Router, Route} from 'react-router-dom'
import { createBrowserHistory } from 'history';
const browserHistory = createBrowserHistory();

import { Provider } from 'react-redux';
import store, { history } from './store';


const router = (
<Provider store={store}>
    <Router history={ browserHistory }>
        <Route path='/' component={Main}>
            <Route exact component={PhotoGrid}></Route>
            <Route path="/view/:postId" component={Single}></Route>
        </Route>
    </Router>
</Provider>

 )

ReactDOM.render(router, document.getElementById('root'));
registerServiceWorker();

The message should also tell you to "search the keywords" for each lint error you see. 该消息还应告诉您针对您看到的每个皮棉错误“搜索关键字”。 If you search the import/first keyword, you will arrive at this description that explains the problem, and how to fix it. 如果您搜索import/first关键字,则将获得此说明 ,以说明问题以及如何解决此问题。

In your case, you need to move out 就您而言,您需要搬出

const browserHistory = createBrowserHistory();

below all import statements. 在所有import语句下方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM