this is the error I am getting
ERROR Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of FetchData.
I created a collection and named it baghdad in Firebase. Everything looks fine but I am getting this error. Here are my codes
----------
FetchData.js
import { View, StyleSheet } from "react-native";
import React from "react";
import firebase from "firebase/compat/app";
import "firebase/compat/auth";
import "firebase/compat/firestore";
const firebaseConfig = {
apiKey: "",
authDomain:"-.m",
projectId: "-",
storageBucket: "-..",
messagingSenderId: "",
appId: "",
};
const firebaseApp = firebase.initializeApp(firebaseConfig);
const db = firebaseApp.firestore();
const auth = firebase.auth();
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
import { Component } from "react";
import { ScrollView, ActivityIndicator } from "react-native";
import { List } from "react-native-paper";
export { auth, db };
class FetchData extends Component {
constructor() {
super();
this.docs = firebase.firestore().collection("baghdad");
this.state = {
isLoading: true,
baghdad: [],
};
}
componentDidMount() {
this.unsubscribe = this.docs.onSnapshot(this.getStudentsData);
}
componentWillUnmount() {
this.unsubscribe();
}
getStudentsData = (querySnapshot) => {
const baghdad = [];
querySnapshot.forEach((res) => {
const { name, business_status } = res.data();
baghdad.push({
key: res.place_id,
name,
business_status,
});
});
this.setState({
baghdad,
isLoading: false,
});
};
render() {
if (this.state.isLoading) {
return (
<View style={styles.loader}>
<ActivityIndicator size="large" color="red" />
</View>
);
}
return (
<ScrollView style={styles.wrapper}>
{this.state.baghdad.map((res, i) => {
return (
<List key={i} bottomDivider>
<List.Content>
<List.Title>{res.name}</List.Title>
<List.Subtitle>{res.business_status}</List.Subtitle>
</List.Content>
<List.Chevron color="black" />
</List>
);
})}
</ScrollView>
);
}
}
const styles = StyleSheet.create({
wrapper: {
flex: 1,
paddingBottom: 22,
},
loader: {
position: "absolute",
alignItems: "center",
justifyContent: "center",
left: 0,
right: 0,
top: 0,
bottom: 0,
},
});
export default FetchData;
---------
App.js
import React from "react";
import FetchData from "./src/FetchData";
export default function App() {
return <FetchData />;
}
Thanks for any help and support