简体   繁体   English

React-Native:Firebase实时数据库如何获取一个数据

[英]React-Native : Firebase Realtime Database How Can I Get One Data

I have this database. 我有这个数据库。 database 数据库

How can i get firstName in React-Native ? 我如何在React-Native中获得firstName?

It's simple in your case : use react-native-firebase 在您的情况下很简单:使用react-native-firebase

import firebase from 'react-native-firebase'


 const ref = firebase.database().ref('users/fwDRY...G3');
 const name = ref.get({ firstname: 'firstname' });
 console.log(name.firstname)

Find yourself helpful from the docs: https://rnfirebase.io/docs/v5.xx/database/reference/database 从文档中发现自己有帮助: https : //rnfirebase.io/docs/v5.xx/database/reference/database

As React Native runs in Java Script thread on mobile platforms there are 2 ways to use it. 由于React Native在移动平台上的Java Script线程中运行,因此有两种使用方式。

  1. Using Web SDK, but it might be slower and is not as well integrated to the mobile operating system as native. 使用Web SDK,但速度可能较慢,并且与本机的集成度不如移动操作系统好。
  2. Using Native SDK for each platform. 为每个平台使用本机SDK。 Using them manually on 2 platforms would require you to write React Native bindings for both platforms. 在2个平台上手动使用它们将需要您为两个平台编写React Native绑定。 Fortunately, the job has already been done. 幸运的是,这项工作已经完成。 I highly recommend you to use this library https://github.com/invertase/react-native-firebase . 我强烈建议您使用此库https://github.com/invertase/react-native-firebase It uses native APIs internally but exposes them into nice JavaScript API. 它在内部使用本机API,但将其公开为漂亮的JavaScript API。 It requires some setup but you won't work it around anyway regardless of the method chosen. 它需要一些设置,但是无论选择哪种方法,您都不会解决它。 For example, to set it up for Android, you need to follow 例如,要针对Android进行设置,您需要遵循

After you set it up, follow the link provided by frank-van-puffelen, https://firebase.google.com/docs/database/web/read-and-write#listen_for_value_events . 设置完之后,请点击frank-van-puffelen提供的链接, 网址为https://firebase.google.com/docs/database/web/read-and-write#listen_for_value_events The API on react-native-firebase is almost the same. react-native-firebase上的API几乎相同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 React Native 中将 Firebase 实时数据库数据值加一? - How to increment Firebase Realtime database data values by one in React Native? 如何将我的 Firebase 数据放入 React-Native Map Marker 而不是 Flatlist - How can I get my Firebase Data into React-Native Map Marker instead of a Flatlist 如何从 Firebase 实时数据库中的一张表中获取数据 - How can I get data from only one table in Firebase Realtime Database 如何在 React Native 应用程序中从 Firebase 实时数据库中获取数据 - How to Fetch Data from Firebase Realtime Database in React Native App 如何在 React Native 中使用 Firebase 实时数据库在本地保存数据? - How to persist data locally with firebase realtime database in react native? 如何从 React Native 中的 firebase 实时数据库获取当前用户数据 - How to get current user data from firebase realtime database in React Native 如何仅获取特殊字段数据 firebase 实时数据库反应原生 - How to get only special field data firebase realtime database react native 如何从 Firebase 实时数据库中获取数据,这些数据是随机密钥的子项 - 使用本机反应? - How do I fetch data from firebase realtime database which are children to a random key - using react native? 如何使用 React Native 从 firebase 实时数据库中获取数据? - How do I get data from firebase realtime databese with React Native? 如何在 react js 中从 firebase 实时数据库中获取数据? - How to get the data from firebase realtime database in react js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM