React本机应用程序显示错误为超时错误?

问题描述 投票:0回答:1

问题:

我正在创建一个带有firebase集成的expo应用程序。在那里,我创建了一个配置文件来连接数据库。这是它的外观。

import Firebase from 'firebase';
 let config = {
    apiKey: "mykey",
    authDomain: "mytrain-5beba.firebaseapp.com",
    databaseURL: "https://mytain-5beba.firebaseio.com",
    projectId: "mytain-5beba",
    storageBucket: "mytain-5beba.appspot.com",
    messagingSenderId: "myid"
  };
let app = Firebase.initializeApp(config);
export const db = app.database();

在services文件夹中,我创建了一个这样的服务文件来处理crud操作。这看起来如何。

import { db } from '../config/db';

export const addItem =  (item) => {
    db.ref('/tains').push({
        name: item
    });
}

在我的组件中在componentDidMount方法中,我做了类似这样的事情来测试天气数据库连接是否正常工作。

import React, { Component } from "react";
import {
  StyleSheet,
  Text,
  TextInput,
  View,
  TouchableOpacity,
  Dimensions,
  Picker,
  ListView
} from "react-native";

import {
  Ionicons,
  Foundation,
  Entypo,
  MaterialCommunityIcons,
  FontAwesome,
  MaterialIcons
} from "@expo/vector-icons";

import { Autocomplete } from "react-native-autocomplete-input";

import { addItem } from '../../services/stationService';

const { height, width } = Dimensions.get("window");
const box_width = width / 2 + 40;

export default class TicketForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: ""
    };
  }

  static navigationOptions = {
    title: "",
    headerStyle: {
      backgroundColor: "#2b78fe"
    },
    headerTintColor: "#fff",
    headerTitleStyle: {
      color: "#ffff"
    }
  };

  componentDidMount() {
    const name = "Tharindu";
    addItem(name);
  }




  render() {
    return (
      <View>
        <Text>Haiii</Text>
      </View>
    );
  }
}


});

当我运行expo start --android时。它向我展示了一些像这样的警告。

[15:59:03] Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.
(Saw setTimeout with duration 92226ms)
- node_modules\react-native\Libraries\ReactNative\YellowBox.js:80:15 in warn
- node_modules\expo\src\Expo.js:26:41 in warn
- ... 11 more stack frames from framework internals

我对这些本土的反应很新。有人可以帮我解决这个问题吗?谢谢!

reactjs firebase react-native
1个回答
1
投票

它是一个firebase计时器问题,暂时忽略它。还没有解决方案

constructor() { super(); console.ignoredYellowBox = [ 'Setting a timer' ]; }

© www.soinside.com 2019 - 2024. All rights reserved.