我是React-native的新手,但之前我已成功将本地文件导入到另一个文件中,并且出现以下错误消息:
Unable to resolve "./common" from "src/components/LoginForm.js"
如果有任何见解,我也将第一次使用expo XDE。这似乎很简单,但是我似乎找不到打字错误。
这是我的项目文件结构的屏幕截图:
这些是我在LoginForm.js中导入的内容
import React, { Component } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { FormLabel, FormInput, FormValidationMessage } from 'react-native-elements';
import { Form, FormSection } from './common'; // what am i doing wrong with this????
这些是我在App.js中的导入
import React from 'react';
import LoginForm from './src/components/LoginForm';
答案 0 :(得分:1)
您必须在index.js
中创建一个/common
,然后导出所有组件:
export * from "./Button";
export * from "./Card";
export * from "./CardSection";
export * from "./Header";
export * from "./Input";
export * from "./Spinner";
还要确保在每个文件中也export { YourComponentName };
!