问题:
我正在创建具有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();
在服务文件夹中,我已经创建了一个服务文件来处理诸如此类的操作。这样看起来。
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时,请启动--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
我对这些本机反应非常陌生。有人可以帮我解决这个问题吗?谢谢!
答案 0 :(得分:1)
存在一个firebase计时器问题,现在暂时忽略它。还没有解决办法
constructor() {
super();
console.ignoredYellowBox = [
'Setting a timer'
];
}