objects are not valid as react child (react-native)

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


objects are not valid as react child (react-native)



I am trying to initialize firebase in my react native project.



This is the error I am facing



code for App.js where I am initialising it is


App.js


import React, {Component} from 'react';
import {View, Text} from 'react-native';
import {Provider} from 'react-redux';
import {createStore} from 'redux';
import reducers from './reducers';
import firebase from 'firebase';

class App extends Component {

componentWillMount () {
const config = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: ""
};
firebase.initializeApp(config);
}

render() {
return (
<Provider store={createStore(reducers)}>
<View>
<Text>Hello! </Text>
</View>
</Provider>
);
}
}

export default App;



I even face the same error when I only include import firebase from 'firebase'; and don't initialize the config


import firebase from 'firebase';


config





This looks like the same error, so I'm linking them just in case: github.com/firebase/firebase-js-sdk/issues/…
– Frank van Puffelen
Jun 7 at 3:09





Had the same problem, cleberton response here fixed it for me.
– Ikechi
Jun 18 at 9:26





Had the same issue, cleberton response here fixed it for me.
– Ikechi
Jun 18 at 9:27




2 Answers
2



Try initializing on constructor instead of componentWillMount


import React, {Component} from 'react';
import {View, Text} from 'react-native';
import {Provider} from 'react-redux';
import {createStore} from 'redux';
import reducers from './reducers';
import firebase from 'firebase';

class App extends Component {

constructor(props){
super(props)
const config = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: ""
};
firebase.initializeApp(config);
}


render() {
return (
<Provider store={createStore(reducers)}>
<View>
<Text>Hello! </Text>
</View>
</Provider>
);
}
}

export default App;





Didn't work! And I repeat the error is mainly due to import firebase from 'firebase'; I need to important it successfully. I have installed firebase using npm install firebase --save in the root directory of project.
– Ansh Gujral
Jun 7 at 3:14




import firebase from 'firebase';


npm install firebase --save



The exports changed at version 5.0.4 and later. Now you need to do it like this:



import firebase from '@firebase/app'


import firebase from '@firebase/app'



If you're using eslint you'll probably get a complaint that it should be listed in the project dependencies, but you can ignore that.



You'll probably also want to use the actual features of firebase rather than just the core import. For example, to use the authentication module you'd add the following:



import '@firebase/auth'


import '@firebase/auth'






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

A5QQqRq0eycFNOjQyR,Oo PPh1Lanen30ov ZjuI3eRZfRFiRgo8F,7hunUM,swIQI6vHl
VHx,l 0NedF,An sBKAUoKvecysV fK5rCQuBOmT3 CTrfJ,d7UVgnNx9Pk0TJOqwv7n,pVFwH7ofF

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham