首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >需求周期: src\components\Login\Login.tsx -> src\components\Login\index.ts -> src\components\Login\Login.tsx

需求周期: src\components\Login\Login.tsx -> src\components\Login\index.ts -> src\components\Login\Login.tsx
EN

Stack Overflow用户
提问于 2022-04-03 14:24:58
回答 1查看 172关注 0票数 0

我做错了什么,为什么我会收到错误信息:

代码语言:javascript
复制
Require cycle: src\components\Login\Login.tsx -> src\components\Login\index.ts -> src\components\Login\Login.tsx

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

登录:

代码语言:javascript
复制
const Login = () => {
 ...
};

export default Login;

风格:

代码语言:javascript
复制
export const s = StyleSheet.create({...})

Model.ts

代码语言:javascript
复制
interface ILogin {
 test: boolean;
}

index.ts

代码语言:javascript
复制
import Login from "./Login";
import { ILogin } from "./Model";
import { s } from './Style';

export {
  Login,
  ILogin,
  s
};

有谁能帮我解决这个问题吗?

欧元:我在登录中的导入:

代码语言:javascript
复制
import React from 'react';
import { Text, View, Image, Dimensions } from 'react-native';
import { Button } from '../Button';
import { Input } from '../Input';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import LottoView from 'lottie-react-native';
import Ionicons from '@expo/vector-icons/Ionicons';
import Feather from '@expo/vector-icons/Feather';
import { InputStyles } from '../Input';
import { ButtonStyles } from '../Button';
import { globalStyles } from '../../shared/GlobalStyles';
import { useTranslation } from 'react-i18next';
import { useNavigation } from '@react-navigation/native';
import { ILogin } from './Model';
import { s } from './Style';
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-03 15:35:34

这个周期意味着您的login.tsx从index.tsx/./中导入一些东西,这反过来又会导入您的login.tsx。因此,您的login.tsx依赖于自身,为了解决这个循环,您应该通过显式导入所需的文件来替换import … from './'

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71726770

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档