"@react-native-firebase/app": "^18.8.0",
"@react-native-firebase/auth": "^18.8.0",
"@react-native-firebase/database": "^18.8.0",
import database from '@react-native-firebase/database';
const customHook = () => {
useEffect(() => {
// Set promise never resolves!!
database().ref('/live_users/<USER_ID>')
.set({ date: new Date() })
.them(() => console.log("success"))
.catch(() => console.log("error"))
},[]);
}
You need to get the database reference from the app.
import { firebase } from '@react-native-firebase/database';
const customHook = () => {
useEffect(() => {
// Now set call should work
firebase
.app()
.database()
.ref('/live_users/<USER_ID>')
.set({ date: new Date() })
.them(() => console.log("success"))
.catch(() => console.log("error"))
},[]);
}