[英]React-Native : Firebase Realtime Database How Can I Get One Data
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线程中运行,因此有两种使用方式。
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.