暫無描述

index.js 562B

1234567891011121314151617181920
  1. import { USER_STATE_CHANGE } from '../constants/index'
  2. import firebase from 'firebase'
  3. //Export to the app to trigger DB action
  4. export function fetchUser(){
  5. return((dispatch) => {
  6. firebase.firestore()
  7. .collection("Users")
  8. .doc(firebase.auth().currentUser.uid)
  9. .get()
  10. .then((snapshot) => {
  11. if(snapshot.exists){
  12. dispatch({type : USER_STATE_CHANGE, currentUser : snapshot.data()})
  13. }
  14. else{
  15. console.log('Does not exist')
  16. }
  17. })
  18. })
  19. }