首页 > 解决方案 > 致力于重构一个反应组件以删除导入/无循环

问题描述

更新

我一直在解决这个问题,感觉我终于找到了这个问题的根源。我去把两张 css 表分开到Header.scss HeaderProfile.scss中,警告仍然出现。

所以看起来这是导致问题的原因:

import/no-cycle

索引.jsx

import { HeaderProfile } from './HeaderProfile';

export type Props = {
  home: Link,
  links: Link[],
  mobileOnly?: any,
  profile?: Profile,
};

标头配置文件

import type { Profile } from './index';

export type Props = {
  profile: Profile,
};

与 Dave 交谈后,问题似乎是我将 HeaderProfile 导入索引,然后需要将配置文件重新导入 HeaderProfile。我正在与 github repo 人员讨论后续步骤

// eslint-disable-next-line import/no-cycle
import { HeaderProfile } from './HeaderProfile';

感谢您提供的任何帮助!

链接到 github 仓库:

https://github.com/ifmeorg/ifme/blob/master/client/app/components/Header

标签: reactjs

解决方案


上面已更新,但出于存档目的而关闭它。有一个循环导入发生,但不像回购中的人所想的那样。在接下来的步骤中与 github repo 人员交谈。问题是他们将 HeaderProfile 导入 index.jsx,然后将 Profile 导入 HeaderProfile


推荐阅读