【发布时间】:2017-04-27 08:06:32
【问题描述】:
我学习了一个使用 React Native 在 Firebase 上保存日期的教程。
当我编译它时显示错误是_firebase2.default.database.ref is not a function
但是官方教程的问题也是.ref。
https://firebase.google.com/docs/database/web/read-and-write
任何人都可以教我如何解决这个问题,在此先感谢。
我在 Firebase 上的规则设置:
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}
在 React Native 中保存数据代码:
export const employeeCreate = ({ name, phone, shift }) => {
const { currentUser } = firebase.auth();
firebase.database.ref(`/users/${currentUser.uid}/employees`)
.push({ name, phone, shift });
};
【问题讨论】:
-
不应该是firebase().database().ref('---whatever---')
-
@ParthGhiya,感谢您回答 firebase.database().ref('---whatever---') 正在工作,非常感谢。
-
我会把它作为答案发布,你可以接受&UpVote
标签: javascript firebase react-native firebase-realtime-database