Reactjs 如何解决道具和同名模块导入之间的eslint冲突?

Reactjs 如何解决道具和同名模块导入之间的eslint冲突?,reactjs,redux,react-redux,eslint,Reactjs,Redux,React Redux,Eslint,我将react与react redux和eslint一起使用。在我的容器中,我导入一个动作,该动作将绑定到mapDispatchToProps中组件的道具,如下所示: // simplified for brevity import { getGames } from '../actions/game'; const mapDispatchToProps = dispatch => ({ getGames: () => dispatch(getGames()) }); cla

我将reactreact reduxeslint一起使用。在我的容器中,我导入一个动作,该动作将绑定到mapDispatchToProps中组件的道具,如下所示:

// simplified for brevity
import { getGames } from '../actions/game';

const mapDispatchToProps = dispatch => ({
  getGames: () => dispatch(getGames())
});

class App extend React.Component {
  // class members
}

export default App connect(mapDispatchToProps)(App);
我将getGames称为componentDidMount:

  componentDidMount () {
    const { getGames } = this.props;
    getGames().then(json => console.log(json));
  }
Eslint坚持使用对象分解从componentDidMount中的this.props中提取值,这很好

问题是,eslint还抱怨当我使用对象解构时,getGames已经在外部范围(import语句)中声明

我想在这两种情况下都使用eslint,但想不出如何在导入和this.props destructure中使用对象销毁,而不会引起命名冲突

任何想法都非常感谢

// simplified for brevity
import { getGames } from '../actions/game';
您可以使用别名

import { getGames as getGames1 } from '../actions/game';
并改用别名

您可以使用别名

import { getGames as getGames1 } from '../actions/game';

并改用别名。

您能提供被投诉的eslint规则名称吗?这可能会有帮助。您能提供被投诉的eslint规则名称吗?这可能会有帮助。