Chciałem mieć dostęp do profilu użytkownika w obiekcie firebase.profile, ale nie wiem czemu obiekt ten cały czas wygląda tak :
isEmpty: true
isLoaded: false
fbConfig.js
import firebase from 'firebase/app'
import 'firebase/firestore'
import 'firebase/auth'
var firebaseConfig = {};
export const rrfConfig = {
userProfile: 'users',
useFirestoreForProfile: true
}
// Initialize Firebase
export const fire = firebase.initializeApp(firebaseConfig);
firebase.firestore().settings({
timestampsInSnapshots : true
});
export default firebase;
index.js
[...]
const store = createStore(
rootReducer,
compose(
applyMiddleware(thunk.withExtraArgument({getFirebase,getFirestore})),
reduxFirestore(firebase, rrfConfig)
)
);
const rrfProps = {
firebase,
config: rrfConfig,
dispatch: store.dispatch,
createFirestoreInstance
}
ReactDOM.render(
<Provider store={store}>
<ReactReduxFirebaseProvider {...rrfProps}>
<App />
</ReactReduxFirebaseProvider>
</Provider>
, document.getElementById('root'));
serviceWorker.unregister();
i NavBar.js
import React from 'react'
import styles from './loggedNavBar.module.css'
import { connect } from 'react-redux'
import { signOut } from '../../store/actions/authActions'
const LoggedNavBar = props => {
return (
<div className={styles.NavBar}>
Zalogowany
<button onClick={props.signOut}>Wyloguj</button>
</div>
)
}
const mapStateToProps = state => {
console.log(state);
return {
userID: state.firebase.auth.uid,
profile: state.firebase.profile
}
}
const mapDispatchToProps = dispatch => {
return {
signOut: () => dispatch(signOut())
}
}
export default connect(mapStateToProps, mapDispatchToProps)(LoggedNavBar);
Wzorowałem się na tych stronach :
https://react-redux-firebase.com/docs/firestore,
https://react-redux-firebase.com/docs/recipes/profile.html
I nie mam pojęcia gdzie może znajdować się błąd...