Closed Dhanushreddy09 closed 4 years ago
reactReduxFirebase
is no longer part of the API, you should instead use the ReactReduxFirebaseProvider
as shown in the setup in the use section of the README. It appears you are using the v2 API, so you may also want to check out the v2 -> v3 migration guide
This is Clients.js file
import React, { Component } from 'react' import {Link} from 'react-router-dom'; import PropTypes from 'prop-types' import {connect} from 'react-redux' import {compose} from 'redux' import {firestoreConnect, withFirestore} from 'react-redux-firebase'
class Clients extends Component { render() { const {clients}=this.props; if(clients){ return (
{''} Clients{''}
} } Clients.propTypes={ clients:PropTypes.array, firestore:PropTypes.object.isRequired } export default compose( withFirestore([{collection:'clients'}], connect((state,props)=>({ clients:state.firestore.ordered.clients }))) ) (Clients);
And store.js file
import firebase from 'firebase' //import 'firebase/auth' import 'firebase/firestore' // <- needed if using firestore // import 'firebase/functions' // <- needed if using httpsCallable import { createStore, combineReducers, compose } from 'redux' import { ReactReduxFirebaseProvider, firebaseReducer, reactReduxFirebase } from 'react-redux-firebase' import { reduxFirestore, firestoreReducer } from 'redux-firestore' // <- needed if using firestore
const fbConfig = {
}
// react-redux-firebase config const rrfConfig = { userProfile: 'users' // useFirestoreForProfile: true // Firestore for Profile instead of Realtime DB // enableClaims: true // Get custom claims along with the profile }
// Initialize firebase instance firebase.initializeApp(fbConfig)
// Initialize other services on firebase instance const firestore=firebase.firestore() // <- needed if using firestore // firebase.functions() // <- needed if using httpsCallable const createStoreWithFirebase=compose( reactReduxFirebase(firebase,rrfConfig), reduxFirestore(firebase) )(createStore) // Add firebase to reducers const rootReducer = combineReducers({ firebase: firebaseReducer, firestore: firestoreReducer // <- needed if using firestore })
// Create store with reducers and initial state const initialState = {} const store = createStoreWithFirebase(rootReducer, initialState,compose( window.REDUX_DEVTOOLS_EXTENSION && window.REDUX_DEVTOOLS_EXTENSION(), reactReduxFirebase(firebase) )) export default store;