1

I take a tutorial to save date on Firebase in React Native.

When i compile it that show the error is _firebase2.default.database.ref is not a function

But the question that offcial tutorial is .ref too. https://firebase.google.com/docs/database/web/read-and-write

Any one can teach me how to solve the issue , thanks in advance.

My rules setting on Firebase:

{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
          ".write": "$uid === auth.uid"
      }
    }
  }
}

Save data code in React Native:

export const employeeCreate = ({ name, phone, shift }) => {

    const { currentUser } = firebase.auth();

    firebase.database.ref(`/users/${currentUser.uid}/employees`)
    .push({ name, phone, shift });

};
AL.
  • 36,815
  • 10
  • 142
  • 281
Morton
  • 5,380
  • 18
  • 63
  • 118

1 Answers1

1

You are using it wrong.

When u directly reference firebase, you should use it like this

firebase().database().ref('---whatever---') 
Parth Ghiya
  • 6,929
  • 2
  • 30
  • 37