Tag: react native

用Node.js连接到MySQL数据库

在我的React Native应用程序中尝试使用Node.JS连接到MySQL数据库时遇到问题。 var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "root", password: "", port: 8889, database: "blabla" }); con.connect(function(err) { if (err) console.log(err); }); 我可以访问phpmyadmin没有任何问题(相同的用户和密码),但是当我执行JS文件terminal似乎加载,但像这样停留: 我不认为和React有联系,但是我真的不知道。 在此先感谢您的帮助

是否有可能将GetStream.io与使用Create React Native App构build的React Native应用程序集成而不popup?

我正在尝试使用getstream.io的客户端function(特别是提要和实时更新),在使用react-native构build的本机应用程序上构buildstream。 当我尝试使用从我的服务器传递的令牌在JavaScript代码中初始化客户端时,出现错误: [Error: Missing app id, which is needed to subscribe, use var client = stream.connect(key, secret, appId);] 但是,当我添加秘密和appId(为了testing目的,我会非常谨慎的部署像这样),我得到的错误: [Error: You are publicly sharing your private key. Dont use the private key while in the browser.] 有没有一种方法来获得运行使用世博会的客户端版本(创buildReact本机应用默认),而不从popup的创build反应本机应用程序?

React-Native项目停留在:app:installDebug

每次运行我的react-native项目时,它都会陷入99%的困境。 我试图运行./Gradlew干净,杀死亚行,但没有任何作品。 我已经使用我的设备通过USB,genymotion和Android工作室模拟器,它总是相同的… 在设备上构build和安装应用程序(cd android && gradlew.bat install Debug)…增量java编译是一项孵化function。 :app:prebuild UP-TO-DATE:app:preDebugBuild UP-TO-DATE:app:checkDebugManifest:app:preReleaseBuild UP-TO-DATE:react-native-maps:preBuild UP-TO-DATE:react-native-maps :preReleaseBuild UP-TO-DATE:react-native-maps:checkReleaseManifest:react-native-maps:preDebugAndroidTestBuild UP-TO-DATE:react-native-maps:preDebugBuild UP-TO-DATE:react-native-maps:preDebugUnitTestBuild UP -TO-DATE:react-native-maps:pre-releaseUnitTestBuild UP-TO-DATE:react-native-maps:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE:react-native-maps:prepareComAndroidSupportSupportV42400Library UP-TO-DATE:react-native-maps: prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library UP-TO-DATE:react-native-maps:prepareComFacebookFrescoDrawee130Library UP-TO-DATE:react-native-maps:prepareComFacebookFrescoFbcore130Library UP-TO-DATE:react-native-maps:prepareComFacebookFrescoFresco130Library UP-TO-DATE:react-native- maps:prepareComFacebookFrescoImagepipeline130Library UP-TO-DATE:react-native-maps: prepareComFacebookFrescoImagepipelineBase130Library UP-TO-DATE:react-native-maps:prepareComFacebookFrescoImagepipelineOkhttp3130Library UP-TO-DATE:react-native-maps:prepareComFacebookReactReactNative0493Library UP-TO-DATE:react-native-maps:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE:react-native- maps:prepareComGoogleAndroidGmsPlayServicesBase1024Library UP-TO-DATE:react-native-maps:prepareComGoogleAndroidGmsPlayServicesBasement1024Library UP-TO-DATE:react-native-maps:prepareComGoogleAndroidGmsPlayServicesMaps1024Library UP-TO-DATE:react-native-maps:prepareComGoogleAndroidGmsPlayServicesTasks1024Library UP-TO-DATE:react- native-maps:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE:react-native-maps:prepareReleaseDependencies:react-native-maps:compileReleaseAidl UP-TO-DATE:react-native-maps:compileReleaseNdk UP-TO-DATE:react-native-maps :compileLint UP-TO-DATE:react-native-maps:copyReleaseLint UP-TO-DATE:react-native-maps:compileReleaseRenderscript UP-TO-DATE: react-native-maps:generateReleaseBuildConfig UP-TO-DATE:react-native-maps:generateReleaseResValues UP-TO-DATE:react-native-maps:generateReleaseResources UP-TO-DATE:react-native-maps:mergeReleaseResources UP-TO- DATE:react-native-maps:processReleaseManifest UP-TO-DATE:react-native-maps:processReleaseResources […]

node-js服务器安全性,以及react-native客户端

林想知道是否有办法只接受来自目标react-native应用程序的http请求。 我的意思是,目前,我的nodejs服务器(使用express)接受来自任何方式的连接(甚至邮递员请求)。 有没有办法让服务器只听所需的应用程序?

如何使用反应本机获得`__dirname`像Node.js

我想获得当前的JavaScript脚本的dirname名称,如node.js中的__dirname 。 我还没有在原文中find文档中的方法,我不知道如何实现这个目的? 或者我如何find静态文件(如.js)? 例如像使用NSDocumentDirectory在iOS中本地定位文件。

麻烦为ReactNative设置领域:`rnpm链接领域`失速没有进一步的信息或输出

我正在尝试为React Native项目设置Realm ,但安装不起作用。 它没有调用rnpm link realm ,没有任何反应。 下面是我采取的步骤(紧接着Realm的RN入门 ): npm install -g rnpm //我需要安装rnpm因为它之前没有安装 react-native init MyDebts npm install –save realm rnpm link realm 我正在使用节点v5.0.0。 请注意,我还为我的package.json添加了更多的依赖关系: 当在项目的目录中调用rnpm link realm时,进程停止,没有任何输出或进一步的信息: 请注意,我尝试了以下故障排除操作,但没有成功: watchman watch-del-all rm -rf node_modules (并重新运行npm install ) 深入清理Xcode(cmd + alt + shift + k) 调用rnpm link realm的结果保持不变(即没有:))。

如何检测模块中的React Native打包程序?

我有一个模块,我用于节点和(现在)反应原生。 我想有select地导出代码取决于它将运行在哪个平台上。 如果你能在设备上运行,你已经解决了这个问题。 模块: if(!react_native){ exports.fs = require('fs'); } exports.print = function(str){ console.log(str); } 在设备上: var m = require('module'); m.print("hello world."); 有没有办法做到这一点? 我不想创build两个单独的模块,只有在不需要index.js时才会有所不同。 谢谢!

在Android上反应本机上传图片

我在Android上有一个反应原生应用程序,而在NodeJS + Express上有一个后端服务器,我用multer来处理file upload。 const multer = require('multer'); const mime = require('mime'); const crypto = require('crypto'); const storage = multer.diskStorage({ destination: (req, file, cb) => cb(null, config.uploads), filename: (req, file, cb) => { crypto.pseudoRandomBytes(16, (err, raw) => { cb(null, raw.toString('hex') + Date.now() + '.' + mime.extension(file.mimetype)); }); } }); const upload = multer({ storage }); […]

尝试使用React Native创build项目时出错

我一直在尝试使用本地反应,并创build一个项目,但一直没有能够这样做。 我正在使用https://facebook.github.io/react-native/docs/getting-started.html中的说明 节点和看守已经安装,然后当我input: npm install -g react-native-cli 我得到这个: /usr/local/bin/react-native -> /usr/local/lib/node_modules/react-native-cli/index.js react-native-cli@1.0.0 /usr/local/lib/node_modules/react-native-cli ├── semver@5.3.0 ├── minimist@1.2.0 ├── chalk@1.1.3 (ansi-styles@2.2.1, escape-string-regexp@1.0.5, supports-color@2.0.0, has-ansi@2.0.0, strip-ansi@3.0.1) └── prompt@0.2.14 (revalidator@0.1.8, pkginfo@0.4.0, read@1.0.7, winston@0.8.3, utile@0.2.1) 当我尝试做: react-native init AwesomeProject 我得到: This will walk you through creating a new React Native project in /Users/jaimito/AwesomeProject Installing react-native package from npm… npm […]

React Native – 后台模式下的Web Socket

我正在开发一个使用反应原生的应用程序,我使用WebSocket与后端进行通信。 即使在后台模式下,我也希望套接字处于活动状态。 我在这里find相关的文章: 如何处理应用程序在后台的套接字连接的事件? 基本上说这是不可能的。 但是,我在模拟器上本地尝试,通过使应用程序进入后台模式,套接字不断接收数据(由远程debugging中仍然发生的日志certificate)。 所以我的问题是,套接字保持活动,甚至应用程序进入后台模式? 或者它只是活跃,因为它只在模拟器上(没有尝试过真正的设备,我的iPhone iOS版本太旧了)。 如果发生这种情况是因为它只是模拟器,除了推送通知之外是否有解决scheme? 附上截图。 提前致谢