Reactjs 正在重构react组件以删除导入/无循环
已更新 我一直在解决这个问题,感觉我终于找到了问题的根源。我去把两张css表分成Header.scs HeaderProfile.scss,警告仍然发生 看来这就是问题的根源:Reactjs 正在重构react组件以删除导入/无循环,reactjs,Reactjs,已更新 我一直在解决这个问题,感觉我终于找到了问题的根源。我去把两张css表分成Header.scs HeaderProfile.scss,警告仍然发生 看来这就是问题的根源: import/no-cycle index.jsx import { HeaderProfile } from './HeaderProfile'; export type Props = { home: Link, links: Link[], mobileOnly?: any, profile?:
import/no-cycle
index.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回购人讨论下一步
// eslint-disable-next-line import/no-cycle
import { HeaderProfile } from './HeaderProfile';
谢谢你的帮助
链接到github回购协议:
以上已更新,但出于存档目的关闭此文件。 有一个循环正在发生,但不像回购协议中的人所想的那样。 与github回购人讨论下一步。
问题是他们正在将HeaderProfile中的文件导入index.jsx,然后将概要文件导入HeaderProfile中不清楚“这是循环逻辑的来源”是什么意思。这里没有显示任何通告。添加了其他信息,感谢Dave的编辑和帮助。我仍然不明白
index.jsx
导入HeaderProfile
<代码>头文件导入头像
。没什么,嗨,戴夫,我感觉我看错了。因此,导致这种情况的另一个原因是index.jsx和ProfileHeader都从scss文件导入css。看来我得想办法把这两个人分开谢谢你的帮助!由于HeaderProfile
导入Profile
,而索引(导出Profile
)导入HeaderProfile
,因此存在循环依赖关系。我假设这是流式或其他什么;我不知道你是否可以用它来外部化你的类型,但是在其他一些系统中你会这么做。