在React Native中加载组件时出现错误

维蒙德

尝试加载组件时出现错误:

无法负载束(HTTP://本地主机:8081 / index.bundle平台= IOS&dev的=真缩小= FALSE),错误:(无法解析模块components/Items/Users/vemundeldegard/AwesomeProject/app/screens/Home.js:模块components/Items不会在急速模块地图存在

这可能与https://github.com/facebook/react-native/issues/4968有关要解决问题,请尝试以下操作:1.清除值班员手表:watchman watch-del-all2.删除node_modules文件夹:rm -rf node_modules && npm install3.重置Metro Bundler缓存:rm -rf /tmp/metro-bundler-cache-*npm start -- --reset-cache4.删除急速缓存:rm -rf /tmp/haste-map-react-native-packager-*(空值))

尝试将我的组件加载到名为screens / home.js的屏幕中,然后将其加载到我的app.js中。

将此添加到/screens/home.js文件的顶部:

import Items from 'components/Items';

然后像这样在渲染器中调用它 <Items />

components / items.js看起来像这样:

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View
} from 'react-native';

const Items = () => {
  return (
    <View>This is now an item</View>
  )
}
export default Items;

为什么无法加载组件?尝试执行错误提示。

在此处输入图片说明

何塞·弗弗

尝试做一下import Items from '../components/items',实际上您的文件名为items(没有大写i)而不是Items

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

React Native:加载自定义组件时出现错误 500

防止加载 React 组件时出现动画

在React Native Image组件中加载本地图像

尝试使用 Victory 图表组件时,React Native 出现组件异常错误

在React Native中加载时的Stack Navigator问题

React Native-导入自定义组件时出现导航错误

子组件加载时在父组件中加载React边栏

构建React Native项目时出现错误

React Native-使用我制作的自定义组件时出现错误(错误:undefined无法解析模块<MyModule>)

如何在React组件中加载脚本

在React组件中加载并显示JSON数据

React native - 在页面加载时从 JSON 动态添加组件

React Native Expo“加载时AppLoading引发意外错误”错误

React Native Expo“加载时AppLoading引发意外错误”错误

组件加载时检测 react js 中的错误

无法在React Native中加载Icon

[React Native]图像无法在Android中加载

在 react-native 中加载动态资产

在组件中加载初始数据时,如何在react-transition-group中暂停动画?

url在react-router v4中加载时组件不呈现

在 react-draft-wysiwyg 编辑器中加载文本时出现问题

React Native,使用Axios发布FormData时出现网络错误

运行react-native run-android时出现错误

React-Native:使用FlatList ref的scrollToIndex时出现错误

获取 react-native 时出现 Blob 数据错误

使用 Switch Case React Native 时出现语法错误

react-native react-thunk 在初始组件加载和输入上的任何按键时触发

类型错误:在 React Enzyme 中加载脚本时无法读取未定义的属性“src”

React Native-组件未加载