Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未使用@react native firebase/database将数据上载到实时数据库_Firebase_React Native - Fatal编程技术网

未使用@react native firebase/database将数据上载到实时数据库

未使用@react native firebase/database将数据上载到实时数据库,firebase,react-native,Firebase,React Native,我在android上使用@react native firebase/database作为应用程序来存储数据。第一天,我能够从firebase中存储和检索数据,但一天后,一切似乎都不起作用。当我在数据库上创建对现有对象的引用以检索数据时,即使我将数据手动存储在数据库中的firebase控制台中,它也不会检索数据。当我使用相同的引用来存储数据时,它不会将该数据存储到firebase控制台,但可以在当时检索该数据。这是暂时的。这意味着,当我将一些数据存储到某个引用时,它会被临时存储,只要应用程序没有

我在android上使用@react native firebase/database作为应用程序来存储数据。第一天,我能够从firebase中存储和检索数据,但一天后,一切似乎都不起作用。当我在数据库上创建对现有对象的引用以检索数据时,即使我将数据手动存储在数据库中的firebase控制台中,它也不会检索数据。当我使用相同的引用来存储数据时,它不会将该数据存储到firebase控制台,但可以在当时检索该数据。这是暂时的。这意味着,当我将一些数据存储到某个引用时,它会被临时存储,只要应用程序没有重新启动,它就可以被检索。重新启动应用程序后,数据将消失。它从未出现在firebase控制台中。提出任何解决方案。提前谢谢。 这是我用来存储和检索数据的代码。 firebase云存储工作正常。 react本机版本0.63.2 @react本机firebase/数据库版本7.5.1

    //code to store data
    import * as React from 'react';
    import {
      Text,
      View,
      StyleSheet,
      TextInput,
      TouchableOpacity,
    } from 'react-native';
    import {Picker} from '@react-native-community/picker';
    import Icon from 'react-native-vector-icons/Feather';
    import database from '@react-native-firebase/database';
    class UploadScreen extends React.Component {
      state = {
        sem: null,
        branch: null,
        subject: null,
        year: null,
        pic: 'mg',
      };
      uploadObject() {
        const databaseRef = database().ref('users');
        console.log(databaseRef);
        const sendObj = databaseRef.push().set({
          sem: this.state.sem,
          branch: this.state.branch,
          subject: this.state.subject,
          year: this.state.year,
        });
      }

    //code to retrieve the data
    import * as React from 'react';
    import {
      Text,
      View,
      StyleSheet,
      TextInput,
      TouchableOpacity,
    } from 'react-native';
    import {Picker} from '@react-native-community/picker';
    import database from '@react-native-firebase/database';
    import Icon from 'react-native-vector-icons/Feather';
    class HomeScreen extends React.Component {
      state = {
        sem: null,
        branch: null,
        subject: null,
        year: null,
        collected: [],
      };

      componentDidMount() {
        const myref = database().ref('users');
        console.log(myref);
        myref.on('value', (snapshot) => {
          console.log(snapshot.val());
        });
      }