Tag: react native

如何为React Native修补/填充crypto.getRandomValues

我使用ReactNativify将一些为NodeJS创build的包移植到React Native,以将Node API对象依赖项重写为他们的browserify等价物。 其中之一是crypto 。 在transformer.js (或.babelrc )中我有: // The following plugin will rewrite imports. Reimplementations of node // libraries such as `assert`, `buffer`, etc. will be picked up // automatically by the React Native packager. All other built-in node // libraries get rewritten to their browserify counterpart. [require('babel-plugin-rewrite-require'), { aliases: { crypto: 'crypto-browserify', // […]

将许多video呈现给客户端的最佳方式是什么?

我有一个nodejs服务器,呈现媒体内容回到我的反应原生移动设备。 可以说我们有100个用户同时在我的移动应用页面上加载100个video。 加载数据的最佳解决scheme是什么?为什么? 我有点卡在使用数据uri / base64编码所有的video内容与简单地从端点获取文件,即 <video src="http://domain/videos/" />. 我倾向于直接加载video文件,因为它会绕过base64编码的video数据; 从而节省移动内存并提高性能。 理想情况下,另一个替代scheme(最佳解决scheme)是通过websocket连接将video数据stream发送回客户端; 那么每个数据块将被传递给video元素进行渲染。 唯一的问题是我不得不base64编码的数据。

同时只运行第一个任务

我正在学习React Native,同时学习打字稿。 我find了一个初始设置的教程,可以一起工作,效果很好。 但是,为了使HRM正常工作,我需要在一个控制台中运行react-native run-android ,并在另一个控制台上npm run watch ,因为这两个任务都控制了控制台。 我下面的教程显示了这个package.json : "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "tsc": "tsc", "clean": "rimraf artifacts", "build": "npm run clean && npm run tsc –", "lint": "tslint src/**/*.ts", "watch": "npm run build — -w", "start:android": "npm run build && concurrently -r \"react-native run-android\" \"npm run watch\"" }, 但是,当我运行start:android它只能得到运行react-native run-android后,它永远不会运行npm […]

React Native / Node API:在发送之后无法设置标题

我遇到了一个与我的Node API交互的原生应用程序的问题。 当我尝试发布数据通过节点更新数据库中的某些值(然后转到存储过程)时,我得到一个500 – 在Node 中发送后,无法设置标题 。 我能find的所有东西都表示这可能是由于发送了两次响应。 我不认为这是这种情况。 我已经在邮递员testing,事情工作正常,它返回正确的返回数据200的状态。 我正在尝试将数据发布到API,如下所示: const myHeaders = new Headers(); myHeaders.append('Content-Type', 'application/json'); fetch(`http://localhost:3000/user/preferences`, { method: 'POST', headers: myHeaders, mode: 'cors', cache: 'default', body: JSON.stringify({ id: '1', minage: this.state.minageValue, maxage: this.state.maxageValue }) }) .then(response => response.json()) .then(body => console.log(body)) .catch(err => console.log(err)); 我在API端接收数据,并将数据传递给存储过程: function updatePreferences(req, res, next) { console.log(req); var […]

React本机应用程序无法在Android中启动,并在debugging版本上显示多条警告消息

环境 react-native-cli:2.0.1,node:v8.2.1,npm:5.3.0, 目标平台:Android 5.0 x86-64图像 开发操作系统:Windows 7专业版,x86_64 的package.json "dependencies": { "axios": "^0.16.2", "buffer": "^5.0.6", "lodash": "^4.17.4", "mobx": "^3.2.1", "mobx-react": "^4.2.2", "react": "16.0.0-alpha.12", "react-native": "0.45.1", "react-native-background-timer": "^1.1.0", "react-native-fetch-blob": "latest", "react-native-timer": "^1.3.1" }, "devDependencies": { "babel-jest": "20.0.3", "babel-preset-react-native": "2.0.0", "jest": "20.0.4", "react-test-renderer": "16.0.0-alpha.12", "tslint": "^5.4.3", "typescript": "^2.4.1", "typings": "^2.1.1" }, 重现步骤 npm安装,npm运行构build,react-native run-android 预期的行为 这应该是在通过USB连接的物理设备上或运行的仿真器上成功启动应用程序。 实际行为 应用程序无法启动这些警告消息: […]

反应本机变换错误

以前有反应,本地运行良好,不记得改变任何东西,然后这个已经certificate不可能清除的错误。 环境Windows 10 react-native-cli:2.0.1 react-native:0.47.1节点v6.11.2 在卸载以前的版本之后全新安装node.js,并从path中删除所有节点和npm目录。 按照https://facebook.github.io/react-native/docs/getting-started.html的新鲜安装react-native react-native init AwesomeProject cd AwesomeProject react-native run-android 也试过了 npm我-g react-native-git-upgrade 反应母语-混帐升级 重新启动,新build项目,卸载节点,重新安装节点,重新安装react-native,新项目。 还是一样的问题。 重复与react-native-git-upgrade v0.47.0想知道是否应该尝试降级到早期版本。 奇怪的是,这是2天前在8-9天前下载并安装的react-native版本。 反复得到同样的错误如下。 在这个上失去了太多的时间。 真的很痛。 开发服务器返回响应错误代码:500 url: http : //10.0.2.2 : 8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false Body:{“message”:“TransformError:D:\ blah \ AwesomeProject \ index.android.js:Unexpected token)(处理预设:\”D:\\ blah \\ AwesomeProject \\ node_modules \\ babel-preset-反应天然\\ index.js \ “)”, “types”: “TransformError”, “LINENUMBER”:0, “说明”: “”, […]

NPM:原生反应的同伴依赖

我试图在我的MacBook上创build我的第一个反应原生应用程序: $ npm install -g react-native-cli 在我的package.json中有 { "dependencies": { "react": "~15.4.0-rc.4", "react-native": "0.41.0", "react-native-image-carousel": "^0.3.2", "react-native-image-picker": "^0.25.7", "react-native-local-mongodb": "^1.8.2" } } 与npm install我得到的消息 npm WARN react-native-image-carousel@0.3.2 requires a peer of react-native@^0.40.0 but none was installed. npm WARN react-swipeable-views-native@0.10.5 requires a peer of react-native@^0.39.0 but none was installed. 我需要做什么?

React-native:Undefined不是一个对象…当使用'react-native-tts'

我想使用文本来发言我的反应原生的应用程序,所以我导入了反原生tts import React from 'react'; import { StyleSheet, View, TouchableHighlight, Image } from 'react-native'; import Tts from 'react-native-tts'; export default class App extends React.Component { constructor(props) { super(props); this._pressConfig = this._pressConfig.bind(this); this._pressPlay = this._pressPlay.bind(this); } _pressConfig() { console.log("pressed"); } _pressPlay() { Tts.speak("Hello world"); } render() { return ( <View style={styles.container}> <View style={styles.navigation}> <TouchableHighlight onPress={this._pressConfig}> <Image […]

卡在“开始包装” – 反应本机

当我运行启动的React Native项目( 你可以在这里看到 ), npm start脚本在Starting packager器上进行扫描 我已经阅读了关于这个问题的这个话题: 反应社区问题:203 反应母语粘连,在启动,打包 反应社区问题:302 但没有一个解决scheme帮助我。 我试图改变观察者的数量,但没有工作。 我试图安装看守,但没有帮助。 一些环境信息: SO:Linux 64位节点v:v7.10.0 任何人都可以帮我吗?

无法parsing模块“react”

我克隆了https://github.com/oblador/react-native-progress 在示例文件夹上: npm i react-native run-ios 但是我得到一个错误,这是错误screenshoot链接: Unable to resolve module react 这是代码: import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Animated, Easing, View, ViewPropTypes, } from 'react-native'; 为什么我的react模块不能解决,但react native模块可以?