Ad
Getting Same Response From A Condition Used In Redux Firebase Saga
I am trying to implement a condition in which I am using Firebase as a database. Condition work if a username already exists. but currently, it is working in both scenarios. like if the username doesn't exist it is still work
Here is my code block in the saga
const snapshot = yield call(rsf.firestore.getDocument,`usernames/${values.username}`);
if(snapshot.data) {
yield put(stopSubmit(form, {username: "Username already exists"}));
return
}
Thanks in advance
Ad
Answer
got the answer it's just a difference of "data" and "exists" the code block for answer :
const snapshot = yield call(rsf.firestore.getDocument,`usernames/${values.username}`);
if(snapshot.exists) {
yield put(stopSubmit(form, {username: "Username already exists"}));
return;
}
Ad
source: stackoverflow.com
Related Questions
- → How can I query Firebase for an equalTo boolean parameter?
- → How can I access nested data in Firebase with React?
- → Firebase simple blog (confused with security rules)
- → Removing item in Firebase with React, re-render returns item undefined
- → AngularJS Unknown Provider Error (Firebase & AngularFire)
- → How do you pass top level component state down to Routes using react-router?
- → "this" is null in firebase query function in reactjs
- → Angular Module Failed to Load
- → Multiple dex files define Lcom/google/android/gms/internal/zzrx;
- → Joining Firebase tables in React
- → How can I make add firepad to my reactjs project?
- → How to use Cloud Functions for Firebase to prerender pages for SEO?
- → React.js component has null state?
Ad