2017-04-27 65 views
0

我參加了一個教程,以在React Native中的Firebase上保存日期。如何保存Firebase上的數據?

當我編譯它,顯示錯誤是_firebase2.default.database.ref is not a function

但是offcial教程問題是.ref了。 https://firebase.google.com/docs/database/web/read-and-write

任何人都可以教我如何解決這個問題,在此先感謝。

我的規則對火力地堡設置:

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

保存數據的代碼陣營母語:

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

    const { currentUser } = firebase.auth(); 

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

}; 
+1

它不應該是火力點()。數據庫()。REF( '---無論---') –

+0

@ParthGhiya,謝謝爲你的答案,firebase.database()。ref('--- whatever ---')正在工作,非常感謝你。 –

+0

我會將它作爲答案發布,你可以接受&UpVote –

回答

1

您正在使用它錯了。

U時直接引用火力點,你應該使用這樣

firebase().database().ref('---whatever---')