反应本机无法读取 null 的属性“绑定”

2024-02-05

我尝试运行一个反应本机模拟器。

然而,在模拟器中却出现了这个错误:

Failed to load bundle(http://localhost:8081/index.bundle?
platform=ios&dev=true&minify=false) 
with error:(/Users/sugawarasyuta/Desktop/albums/index.js:
Cannot read property 'bindings' of null(null))

我仔细检查了我的代码语法。但我觉得这不是那个。你知道如何解决这个错误吗?

这是我的文件:

index.js

import React from 'react';
import { AppRegistry,View } from 'react-native';
import Header from './src/components/header';
import AlbumList from './src/components/AlbumList';


//Create a component
const App = () => (
<View>
<Header headerText= {'albums'} />
<AlbumList />
</View>
);

AppRegistry.registerComponent('albums', () => App );

专辑列表.js

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

class AlbumList extends Component {

componentWillMount(){
    axios.get('https://rallycoding.herokuapp.com/api/music_albums')
    .then(response => console.log(response));

}
render(){
return(
    <View>
        <Text>AlbumList!!!</Text>
    </View>
    );
}
}
export default AlbumList;

这些是终端语句:

/usr/bin/codesign --force --sign - --entitlements /Users/sugawarasyuta/Desktop/albums/ios/build/Build/Intermediates.noindex/albums.build/Debug-iphonesimulator/albums.build/albums.app.xcent --timestamp=none /Users/sugawarasyuta/Desktop/albums/ios/build/Build/Products/Debug-iphonesimulator/albums.app

/Users/sugawarasyuta/Desktop/albums/ios/build/Build/Products/Debug-iphonesimulator/albums.app: resource fork, Finder information, or similar detritus not allowed

Command /usr/bin/codesign failed with exit code 1



** BUILD FAILED **


The following build commands failed:

    CodeSign build/Build/Products/Debug-iphonesimulator/albums.app
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/albums.app
Launching org.reactjs.native.example.albums
org.reactjs.native.example.albums: 8385

这是我的package.json。这些依赖关系正确吗?

{
"name": "albums",  
"version": "0.0.1",

"private": true,

"scripts": {
 "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },


  "dependencies": {

"axios": "^0.18.0",

"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",

"react": "16.3.1",

"react-native": "^0.56.0"

 },

"devDependencies": {

"@babel/preset-env": "^7.0.0-beta.53",

"babel-jest": "23.0.1",

"babel-preset-es2015": "^6.24.1",

 "babel-preset-react-native": "4.0.0",

"eslint-config-rallycoding": "^3.2.0",

 "jest": "23.1.0",

"react-test-renderer": "16.3.1"

},

"jest": {

 "preset": "react-native"

 }

}

我升级了"babel-preset-react-native" from "4.0.0" to "^5.0.1"又出现了一个错误:

error: bundling failed: SyntaxError: 
/Users/sugawarasyuta/Desktop/albums/index.js: Unexpected token (11:3)



  10 | const App = () => {

> 11 |    <Header headerText= {'albums'} />

     |    ^

  12 | 

  13 | };



at Parser.raise

(/Users/sugawarasyuta/Desktop/albums/node_modules
/@babel/core/node_modules/babylon/lib/index.js:776:15)

at Parser.unexpected    
(/Users/sugawarasyuta/Desktop/albums/node_modules/
@babel/core/node_modules/babylon/lib/index.js:2079:16)

at Parser.parseExprAtom (/Users/sugawarasyuta/Desktop/albums/node_modules/@babel/core/node_modules/babylon/lib/index.js:3157:20)

at Parser.parseExprSubscripts (/Users/sugawarasyuta/Desktop/albums/node_modules/@babel/core/node_modules/babylon/lib/index.js:2757:21)

at Parser.parseMaybeUnary (/Users/sugawarasyuta/Desktop/albums/node_modules/@babel/core/node_modules/babylon/lib/index.js:2736:21)

at Parser.parseExprOps (/Users/sugawarasyuta/Desktop/albums/node_modules/@babel/core/node_modules/babylon/lib/index.js:2643:21)

at Parser.parseMaybeConditional (/Users/sugawarasyuta/Desktop/albums/node_modules/@babel/core/node_modules/babylon/lib/index.js:2615:21)

at Parser.parseMaybeAssign (/Users/sugawarasyuta/Desktop/albums/node_modules/@babel/core/node_modules/babylon/lib/index.js:2562:21)

at Parser.parseExpression (/Users/sugawarasyuta/Desktop/albums/node_modules/@babel/core/node_modules/babylon/lib/index.js:2515:21)

at Parser.parseStatementContent (/Users/sugawarasyuta/Desktop/albums/node_modules/@babel/core/node_modules/babylon/lib/index.js:4076:21)
 BUNDLE  [ios, dev] ../../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

我觉得这不仅仅是因为语法错误,而是依赖关系的原因。你知道我该如何修复它吗?


没有任何进一步的信息,我怀疑你需要更新 babel-preset-react-native。

升级到 0.56 时,请确保升级您的 babel-preset-react-native package.json 依赖于 ^5.0.1 或更高版本。

https://github.com/facebook/react-native/releases https://github.com/facebook/react-native/releases

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

反应本机无法读取 null 的属性“绑定” 的相关文章

随机推荐

  • get_the_id 与 post->ID 与 the_id / get_post_meta

    我认为这一定是一个非常基本的问题 但我才刚刚开始 有人可以看一下下面相同 代码的 3 个版本并说出有什么区别吗 所有这些似乎在我正在处理的循环中都工作得很好 应该使用哪个 post gt ID the ID or get the id 是否
  • 如何从 Delphi 的主线程向 TThread 发送消息?

    我想向一个线程发送消息并在线程中处理它 我怎样才能在德尔福中做到这一点 我猜PostMessage是要走的路 但到目前为止我看到的例子描述的是另一种方式 即从线程到主线程 我什至不会尝试解释或编写任何代码 看看这个教程就知道了 它有点旧 但
  • 在启用 PyCharm 插件的情况下使用 CLion 逐步执行 C++ 代码

    启用 PyCharm 插件后 我在 CLion 中遇到问题 这就是我所做的 从 shell 运行 Python 程序 该程序创建多个进程 如工作进程 其中 Python 代码调用我想要调试的 C 代码 从 CLion 附加到原始主 Pyth
  • 在 MySQL 列中查找双引号

    我想查找带双引号的数据 我有下一个简单的查询 SELECT FROM table name WHERE column name LIKE 但我有语法错误 You have an error in your SQL syntax check
  • 在单个系统上运行客户端/服务器程序

    我想知道是否有两个程序 一个叫做server另一个叫client这两个分别说明了服务器和客户端 是否可以在一台机器上测试它们 考虑到我定义客户端套接字如下 socket new Socket 127 0 0 1 3000 编辑 服务器部分
  • 未找到“Aws\Common\Aws”类 cakephp

    我在 cakephp 中使用 AWS PHP SDK V2 8 我正在 AWS ec2 ubuntu 机器上工作 我使用 zip 文件而不是任何作曲家 我收到以下错误 Class Aws Common Aws not found 我创建了一
  • 在自己的函数中响应导航 onPress

    我已经实现了教程中的 React Navigation 示例https reactnavigation org docs intro https reactnavigation org docs intro 而且效果很好
  • 在 Spring boot 中禁用自动提交不起作用

    我设置了两个参数以通过 False 禁用自动提交 但在没有提交事务的情况下保存实体操作 spring datasource hikari auto commit false spring jpa properties hibernate c
  • 在我的文本区域中显示降价

    我正在使用 BlueCloth 从用户输入文本区域的内容中通过 markdown 创建 html 如下所示 def create post Post new params post do post body BlueCloth new po
  • 我的 Android 应用程序 ViewPager 中 PagerTabStrip 的自定义字体颜色

    我需要更改 Android 应用程序 ViewPager 中 PagerTabStrip 的字体颜色 这是相同的 xml 布局 我有什么办法可以做到这一点吗
  • 如何在Java中将文件/目录移动到回收站而不是永久删除它[重复]

    这个问题在这里已经有答案了 我正在尝试创建 GUI 示例 当用户单击按钮时删除文件和 或目录 但我看到文件被永久删除 如何使其移动到回收站而不是这个 if File path getText isEmpty JOptionPane show
  • NodeJS 文件系统观察抛出事件两次或更多次

    我正在 Ubuntu 上使用以下命令查看 NodeJS 服务器的配置文件 for var index in cfgFiles fs watch cfgFiles index function event fileName logger in
  • python argparse子命令具有依赖性和冲突

    我想使用 argparse 来构建一个带有子命令的工具 可能的语法可以是 tool py 下载 from 1234 interval 60 tool py 下载 build 1432 tool py clean 数字 10 所以我想使用ar
  • iOS AVExportSession 仅因修剪视频而失败

    我创建了一种根据给定时间范围修剪和导出视频的方法 它还会将视频旋转为横向 但由于某种原因 AVAssetExportSession 在尝试处理之前使用 UIVideoEditorController 修剪的视频时失败 以前有人遇到过这个问题
  • Errno::EACCES:运行捆绑包时权限被拒绝,它命中 json 1.8.1,pg 0.17

    我刚刚买了一台新笔记本电脑 并使用迁移助手完全转移了所有内容 似乎一切正常并且处于适当的位置 所以我不知道这是否是问题所在 我对调试这样的环境错误还很陌生 我一直在 Windows 上开发一个 Rails 项目 这台笔记本电脑是 Mac O
  • Python 字符串中的 u'\ufeff'

    我收到错误并显示以下异常消息 UnicodeEncodeError ascii codec can t encode character u ufeff in position 155 ordinal not in range 128 不知
  • JScrollPane 中的滚动更平滑

    使用 JScrollPane 的滚动条箭头进行滚动 或通过为箭头键设置键绑定 将视口移动一个增量 暂停 然后平滑滚动 我遇到的大多数滚动条的行为都是一样的 有轻微的移动 暂停 然后更快地连续滚动 有什么方法可以避免暂停 以便滚动从开始到结束
  • C 中的重音/元音字符?

    我刚刚学习 C 语言 并接到了一项作业 要求我们将纯文本翻译成莫尔斯电码 然后再翻译回来 我最熟悉 Java 所以请耐心等待我使用的术语 为此 我有一个包含所有字母字符串的数组 char letters etc 我编写了一个函数来返回所需字
  • Python Discord.py `time.sleep()` 协程

    import discord import os import random import time import math client discord Client with open admins conf r as f for li
  • 反应本机无法读取 null 的属性“绑定”

    我尝试运行一个反应本机模拟器 然而 在模拟器中却出现了这个错误 Failed to load bundle http localhost 8081 index bundle platform ios dev true minify fals