Tag: react native

将React-Native应用程序分解为可插入的模块

我正在寻找一个React-Native应用程序。 我希望能够在设备上运行时下载新模块以扩展function。 将会有一些核心逻辑知道如何基于某种forms的input请求新的模块,如dbs。 我不想将所有东西都捆绑到一个单一的捆绑包中,而这正是我现在用内置的包装器发生的事情。 这与RequireJS在浏览器中的工作方式类似。 我需要知道的是: 我如何构build独立的模块? react-native bundle似乎不允许我select哪个根模块开始,只能在root项目上工作 我如何在运行时请求将新function注入到当前的JavaScript环境中?

React需要rnpm链接的本地组件依赖

我刚刚为React-Native创build了一个组件,我将尽快将它作为一个包加载到npm中。 虽然我面临一个问题。 该组件依赖于另一个名为react-native-image-resizer npm软件包。 这个软件包需要与rnpm连接才能工作。 虽然,当我只是将我的组件安装在一个全新的项目中时,依赖关系将不会自动链接,并且本地库不会出现在项目中。 当然,当我运行rnpm link ,也不会将其添加到项目中。 所以我想知道什么是最好的方式来安装和链接此依赖? MacBook-Pro:Example $ npm install react-native-image-crop > react-native-image-crop@1.0.0 preinstall /Users/alexmngn/Work/react-native-image-crop/Example/node_modules/.staging/react-native-image-crop-95365d1b > npm install –save react-native-image-resizer react-native-image-crop@1.0.0 (git+ssh://git@github.com/alexmngn/react-native-image-crop.git#90e002c7d0f01c9d61277c30cad375560f09a94a) /Users/alexmngn/Work/react-native-image-crop/Example/node_modules/.staging/react-native-image-crop-95365d1b ├── UNMET DEPENDENCY react-native@^0.31.0 └── react-native-image-resizer@0.0.9 npm WARN react-native-image-resizer@0.0.9 requires a peer of react-native@>=v0.14.2 but none was installed. npm WARN react-native-image-crop@1.0.0 No repository field. – react-native-image-resizer@0.0.9 node_modules/react-native-image-crop/node_modules/react-native-image-resizer Example@0.0.1 […]

如何解决反应原生EventEmitterListener警告

我正在使用事件发射器在地图组件和工具栏之间进行通信。 注意*我在我的应用程序的其他部分使用相同的代码没有问题。 我得到的错误是: 警告:setState(…):只能更新已安装或已安装的组件。 这通常意味着您在卸载的组件上调用了setState()。 这是一个没有操作。 请检查未定义组件的代码。 我试图解决这个类似的post,但它不工作。 我认为这两个组件的挂载&&卸载方法? 工具栏组件 componentDidMount() { this.showLocateIconListener = AppEventEmitter.addListener('isTrip', this.isTrip.bind(this)); this.endTripListener = AppEventEmitter.addListener('showLocateIcon', this.showLocateIcon.bind(this)); this.endSubdivisionIcon = AppEventEmitter.addListener('showSubdivisionIcon', this.showSubdivisionIcon.bind(this)); } componentWillUnMount() { this.showLocateIconListener.remove(); this.endTripListener.remove(); this.endSubdivisionIcon.remove(); } //// this is where the error is happening showSubdivisionIcon(val) { if (val != 0) this.setState({ items: menuSubdivision, subdivisionId: val }) else this.setState({ items: menu […]

在Android上运行NodeJS的可行选项(2017年8月)

有一堆旧的线程处理在Android上运行NodeJS。 其中大部分不再可行(JXCore)和/或提供令人困惑,过时,不完整或错误的信息。 因此,我调查了目前似乎是(截至2017年8月)可行的方法,并find了三个可能的候选人。 要决定他们之间我想知道: 这些方法之间的主要区别 在每种方法上具体的亲和和骗局 可能的障碍,挑战和缺点 你知道其他可行的select吗? 可行的方法是 : 运行包含NodeJS ( J2V8 )的V8 javascript引擎, 直接使用NodeJS,embedded为本机库( node-on-android ) 将React Native与NodeJS应用程序即服务( react-native-node ) 除此之外,我发现了一些相关的有趣资源: NPM直接使用Termux直接安装NodeJS而不生根(不适用于最终用户) LiquidCore – 原生移动微应用程序devenv(没有调查,有趣的概念) dna2oslab – 为节点可执行文件提供了一个工作的NodeJS构build脚本 为Android构buildNodeJS – 使用有用的编译技巧和示例项目的博客

React Native初学者项目捆绑失败,出现意外令牌错误

我正在尝试使用https://facebook.github.io/react-native/docs/getting-started.html上的说明为Android创build我的第一个React Native应用程序。 设置依赖关系并连接我的Android设备后,我跑了 react-native init app cd app react-native run-android 这将启动React Packager,该错误与此错误捆绑失败: 错误:捆绑失败:“TransformError:/Users/luky/dev/app/index.android.js:Unexpected token)(处理预设:\”/ Users / luky / dev / app / node_modules / babel-preset-react-本地/ index.js \ “)” 我在用: OSX El Capitan 10.11.6。 节点版本6.9.2 react-native版本0.47.1。 我将生成的项目(包括node_modules)推送到Github,以防万一: https : //github.com/luky1971/react-native-app 有谁知道为什么我可能会得到一个意外的令牌错误? 任何帮助将不胜感激!

xcode使用错误的node.js版本

我是React Native的新手。 我使用了react-native init XXX来创build一个新的项目。 当启动xcodeproj,我得到一个错误说: const setupEnvScript = /^win/.test(process.platform) ^^^^^ SyntaxError: Use of const in strict mode. at Module._compile (module.js:439:25) at Module._extensions..js (module.js:474:10) at Object.require.extensions.(anonymous function) [as .js] (/Users/allanhahaha/Documents/Seat/getseat/SeatApp/node_modules/react-native/node_modules/babel-core/lib/api/register/node.js:214:7) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/Users/allanhahaha/Documents/Seat/getseat/SeatApp/node_modules/react-native/cli.js:15:18) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) 根据我的研究,这是一个node.js版本问题:我应该使用v4.0 +。 我正在使用NVM来pipe理我的node.js版本。 在常规的terminal窗口中 […]

React-Native包装程序失败:重复的模块名称

这在发展过程中看似随机发生。 当试图运行npm start或react-native run-ios ,出现以下错误: Failed to build DependencyGraph: @providesModule naming collision: Duplicate module name: react-native-vector-icons Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json This error is caused by a @providesModule declaration with the same name accross two different files. Error: @providesModule naming collision: Duplicate module name: react-native-vector-icons Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json This error is caused by […]

新鲜的反应,本机ios应用程序不build设?

以下是关于我的环境和构build失败日志的详细信息。 任何面临类似的问题或知道步骤来克服这个问题,请指出我的相关步骤或文档。 Xcode:7.2.1 节点:v5.9.0 npm:3.7.3 react-native-cli:0.1.10 react-native:0.22.2 运行“sudo react-native run-ios”会给我留下下面的日志。 日志: ** BUILD FAILED ** The following build commands failed: PhaseScriptExecution Run\ Script /Users/abc/Desktop/REACT-NATIVE/demo/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Script-006B79A01A781F38006873D1.sh (1 failure) Installing build/Build/Products/Debug-iphonesimulator/demo.app No devices are booted. Print: Entry, ":CFBundleIdentifier", Does Not Exist /Users/abc/Desktop/REACT-NATIVE/demo/node_modules/promise/lib/done.js:10 throw err; ^ Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/demo.app/Info.plist Print: Entry, ":CFBundleIdentifier", Does Not Exist […]

反应本地和socket.io节点不工作

下面是我尝试连接到我的节点websocket后端的原始组件和节点server.js代码。 我的反应代码与服务器在同一台计算机上运行。 我在这里发现了很多不同的答案,而且github,我都无法工作。 我也发现这个问题从来没有答案, 这个问题有一个答案,我不能工作(一年前被问) 我发现这篇文章,并试图根据这些指导方针修改我的代码,但是这不起作用。 反应代码 import React from 'react'; import { StyleSheet, Text, View, Image } from 'react-native'; const io = require('socket.io-client/socket.io'); let socket = io('http://localhost:3000'); export default class App extends React.Component { constructor(props) { super(props); console.log(socket); } render() { return ( <View> <Text>Websocket</Text> </View> ); } } server.js const express = require('express'); […]

React Native:获取请求失败,错误 – TypeError:networking请求失败(…)

我正在开发一个使用React Native的简单应用程序。 我正在Android设备上testing它。 我创build了一个Node.js服务器来侦听请求,它运行在http:// localhost:3333 /上 。 接下来,我正在从index.android.js提取一个请求。 下面是代码。 fetch('http://localhost:3333/', { 'method': 'GET', 'headers': { 'Accept': 'text/plain', } } ) .then((response) => response.text()) .then((responseText) => { console.log(responseText); }) .catch((error) => { console.warn(error); }); 下面是节点服务器上的请求处理程序的代码 app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); }); app.use(express.static('public')); app.get('/', function(req, res){ console.log('Request received for /'); […]