我的js文件中有以下内容:
import { NativeRouter, Route, Link } from 'react-router-native'
运行eslint时出现以下错误:
error Route not found in 'react-router-native' import/named
但是我的应用程序运行得非常好,我只是在运行eslint时遇到错误。这是为什么?
来自package.json:
"eslint": "^4.15.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-react-native": "^2.0.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1",
"eslint-plugin-react-native": "^3.2.1",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-router-native": "^4.2.0",
答案 0 :(得分:0)
看起来eslint报告正确。将js更改为:
后,我不再收到错误import { NativeRouter, Link } from 'react-router-native'
import { Route } from 'react-router'
规则说所有命名导入都必须是命名导出集的一部分:https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md
react-router-native
正在从Route
重新导出react-router
,但在从react-router-native
重新导出时未命名
/[\x{0B00}\x{2032}\x{2033}\s]/+
。至少这是我的理解。