I'm new to React Native and doing a project following some online tutorials. In given step, I have created a Firebase database (also added some dummy data and set a standard rule). In my React Native project, to fetch data after user being authenticated from Firebase, I'm doing following action :
import firebase from 'firebase';
export const loadInitialContacts = () =>
{
const {currentUser} = firebase.auth();
return (dispatch) => {
firebase.database.ref(`/users/${currentUser.uid}/people`)
.on('value', snapshot => {
dispatch({type: 'INITIAL_FETCH', payload: snapshot.val()});
});
};
};
I'm calling the above method from my list view Component :
componentWillMount()
{
this.props.loadInitialContacts();
}
Authentication to Firebase pass successfully, at the time of fetching data from Firebase it throws exception :
Error: TypeError: TypeError: _firebase2.default.database.ref is not a function
What I'm doing wrong?
Looking into the package.json, I'm on this following version :
"dependencies": {
"firebase": "^5.0.2",
"lodash": "^4.17.10",
"react": "16.3.1",
"react-native": "^0.55.4",
...
},
firebase.database().reffirebase.database.ref.on('value', snapshot => {never pass successfully.