Est*_*nte 6 javascript firebase react-native google-cloud-firestore
编辑 - 问题已解决
最后,在收到支持的样本和意见,并做了无数次测试后,我决定取消该项目并重新开始。我无法说出或解释我做错了什么或问题是如何纠正的,我刚刚从头开始了一个项目,一切都奏效了。
我必须说我已经完成了以下问题中显示的所有内容,但无法将数据从数据库带到我的应用程序:
@firebase/firestore:Firestore (5.0.4):无法访问 Cloud Firestore 后端。后端在 10 秒内没有响应
React Native 无法访问 Cloud Firestore 后端
模拟 firstore:Firestore (8.5.0):无法访问 Cloud Firestore 后端
我已经更改了 Firebase 的版本,我添加了对其他人有效的代码,我在 GitHub 上寻找了解决方案,等等。我也在这个站点上寻找了一个解决方案,但我无法连接。
我的 React Native App 使用了 Firebase。我正在尝试将 Firestore 数据库加入我的应用程序,但没有成功。到目前为止,该应用程序有一个数据库中的产品列表,从一个 Web 应用程序手动输入,该应用程序与 Firebase 数据库制作调试器完美连接,我检查修复程序是否到达我,多亏了 console.log,但它是空的,在数据库中我手动输入了几个元素。
我显示了来自 console.log 的图像
我总是收到相同的警告:
> @ firebase / firestore: Firestore (7.19.0): Could not reach Cloud
> Firestore backend. Backend didn't respond within 10 seconds. This
> typically indicates that your device does not have a healthy Internet
> connection at the moment. The client will operate in offline mode
> until it is able to successfully connect to the backend
Run Code Online (Sandbox Code Playgroud)
他们已经是 10 天的测试解决方案。我更改了 Firebase 的版本,添加了适用于其他人的代码,在 GitHub 上寻找答案等。我也在此站点上寻找了解决方案,但无法连接。
如果我无法从数据库中获取数据,我将无法继续我的应用程序
我显示图像和代码
> @ firebase / firestore: Firestore (7.19.0): Could not reach Cloud
> Firestore backend. Backend didn't respond within 10 seconds. This
> typically indicates that your device does not have a healthy Internet
> connection at the moment. The client will operate in offline mode
> until it is able to successfully connect to the backend
Run Code Online (Sandbox Code Playgroud)
文件菜单.js
import app from 'firebase/app'
import 'firebase/firestore'
import firebaseConfig from './config'
class Firebase {
/*constructor() {
if(!app.apps.length) {
app.initializeApp(firebaseConfig)
}
this.db = app.firestore()
}*/
constructor() {
if (!app.apps.length) {
app.initializeApp(firebaseConfig)
app.firestore().settings({ experimentalForceLongPolling: true })
}
this.db = app.firestore()
}
}
const firebase = new Firebase()
export default firebase
Run Code Online (Sandbox Code Playgroud)
文件 NuevaOrden.js
import React, { useContext, useEffect, Fragment } from 'react'
import { StyleSheet } from 'react-native'
import {
Container,
Separator,
Content,
List,
ListItem,
Thumbnail,
Text,
Body
} from 'native-base'
import globalStyles from '../styles/global'
import FirebaseContext from '../context/firebase/firebaseContext'
const Menu = () => {
// Context de Firebase
const { menu, obtenerProductos } = useContext(FirebaseContext)
useEffect(() => {
obtenerProductos()
console.log(menu)
}, [])
return (
<Container style={globalStyles.contenedor}>
<Content style={{ backgroundColor: '#FFF' }}>
<List>
{menu.map(plato => {
const { imagen, nombre, descripcion, categoria, precio, id } = plato
return (
<Fragment key={id}>
<ListItem
>
<Body>
<Text>{nombre}</Text>
</Body>
</ListItem>
</Fragment>
)
})}
</List>
</Content>
</Container>
)
}
const styles = StyleSheet.create({
separador: {
backgroundColor: '#000',
},
separadorTexto: {
color: '#FFDA00',
fontWeight: 'bold',
textTransform: 'uppercase'
}
})
export default Menu
Run Code Online (Sandbox Code Playgroud)
文件 firebaseState.js
import React from 'react'
import { View, StyleSheet } from 'react-native'
import { Container, Button, Text, NativeBaseProvider } from 'native-base'
import globalStyles from '../styles/global'
import { useNavigation } from '@react-navigation/native'
const NuevaOrden = () => {
const navigation = useNavigation()
return (
<Container style={globalStyles.contenedor}>
<View style={[globalStyles.contenido, styles.contenido]}>
<Button
style={globalStyles.boton}
rounded
block
onPress={() => navigation.navigate('Menu')}
>
<Text style={globalStyles.botonTexto} >Crear Nueva Orden</Text>
</Button>
</View>
</Container>
)
}
const styles = StyleSheet.create({
contenido: {
flexDirection: 'column',
justifyContent: 'center'
}
})
export default NuevaOrden
Run Code Online (Sandbox Code Playgroud)
在此处输入图片说明
归档时间: |
|
查看次数: |
199 次 |
最近记录: |