prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 556 forks source link

I have come across this error "cannot call a class as a function" .can someone help me out with this.Thank u in advance !:) #941

Closed Dhanushreddy09 closed 4 years ago

Dhanushreddy09 commented 4 years ago

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{''}

                </div>
            </div>
            <table className="table table-stripped">
                <thead className="thead inverse">
                    <tr>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Balance</th>
                        <th />
                    </tr>
                </thead>
                <tbody>
                    {clients.map(client=>(
                        <tr key={client.id}>
                            <td>{client.firstName} {client.lastName}</td>
                             <td>{client.email}</td>
                            <td>${parseFloat(client.balance).toFixed('2')}</td>
                             <td>
                                 <Link to={`/client/${client.id}`} className="btn btn-secondary btn-sm">
                                    <i className="fas fa-arrow-circle-right">Details</i>
                                 </Link>
                             </td>
                        </tr>
                    ))}
                </tbody>
            </table>
        </div>
    )
}else{
    return <h1>Loading...</h1>
}

} } 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 = {

apiKey: "AIzaSyB-pyEKd5G3XqLokxcYsa66UsG8a_y0gMA",
authDomain: "reactclientpanel-27246.firebaseapp.com",
databaseURL: "https://reactclientpanel-27246.firebaseio.com",
projectId: "reactclientpanel-27246",
storageBucket: "reactclientpanel-27246.appspot.com",
messagingSenderId: "466401447116",

}

// 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;

prescottprue commented 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