I know this might be a stupid ass question, but I have been trying to get this working for weeks.
I am trying to query data from my Firebase Cloud Firestore, and it works in the console with the following:
firestore.collection("tips").onSnapshot(function(querySnapshot) {
const pusher = [];
querySnapshot.forEach(function(doc) {
pusher.push({
tips: doc.data().tips,
user: doc.data().user,
date: doc.data().date,
});
});
console.log(pusher);
});
But then I try to output it to a Flatlist:
export default class Home extends Component {
constructor(props){
super(props);
this.state = ({
pusher: [],
});
}
render() {
return (
<Flatlist
data={this.state.pusher}
renderItem={({ item, index}) => {
return (
<Text>{item.tips}</Text>
)
}}
>
</Flatlist>
)
}
I get this error:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of
Home.This error is located at: in RCTScrollContentView (at ScrollView.js:955) in RCTScrollView (at ScrollView.js:1070) in ScrollView (at KeyboardAwareHOC.js:397) in _class (at Content.js:125) in Content (at connectStyle.js:384) in Styled(Content) (at Home.js:86) in RCTView (at View.js:43) in Container (at connectStyle.js:384) in Styled(Container) (at Home.js:85) in Home (at SceneView.js:9) in SceneView (at StackViewLayout.js:574) in RCTView (at View.js:43) in AnimatedComponent (at StackViewCard.js:12) in Card (at createPointerEventsContainer.js:28) in Container (at StackViewLayout.js:612) in RCTView (at View.js:43) in RCTView (at View.js:43) in StackViewLayout (at withOrientation.js:30) in withOrientation (at StackView.js:63) in RCTView (at View.js:43) in Transitioner (at StackView.js:21) in StackView (at createNavigator.js:59) in Navigator (at createKeyboardAwareNavigator.js:11) in KeyboardAwareNavigator (at createNavigationContainer.js:376) in NavigationContainer (at renderApplication.js:32) in RCTView (at View.js:43) in RCTView (at View.js:43) in AppContainer (at renderApplication.js:31)
getFiberTagFromObjectType 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:19412:15 createFiberFromElement 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:19370:26 createChild 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:21491:34 reconcileChildrenArray 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:21720:31 reconcileChildFibers 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:22006:20 reconcileChildrenAtExpirationTime 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:22353:34 reconcileChildren 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:22348:9 updateHostComponent 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:22618:9 beginWork 7a29fe2c-d11b-4ce4-b2b9-0f3bcbe09827:23027:20
