require cycle: src\components\Login\Login.tsx -> src\components\Login\index.ts



我做错了什么以及为什么收到错误消息:

Require cycle: srccomponentsLoginLogin.tsx -> srccomponentsLoginindex.ts -> srccomponentsLoginLogin.tsx
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

登录:

const Login = () => {
...
};
export default Login;

风格:

export const s = StyleSheet.create({...})

模型.ts

interface ILogin {
test: boolean;
}

索引.ts

import Login from "./Login";
import { ILogin } from "./Model";
import { s } from './Style';
export {
Login,
ILogin,
s
};

任何人都可以帮我解决这个问题吗?

€: 我的导入登录:

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';

这个循环意味着你的login.tsxindex.tsx/./导入一些东西,而index.tsx又会再次导入你的login.tsx。因此,您的login.tsx有点取决于自身,为了解决循环,您应该通过显式导入所需的文件来替换import … from './'

相关内容

最新更新