TypeError:Object(...)不是index.js上的函数 [英] TypeError: Object(...) is not a function on index.js
问题描述
当我运行我的代码时,在浏览器中出现此错误:
Hi i get this error when in my browser when i run my code:
TypeError:Object(...)不是函数 ./src/index.js src/index.js:31
TypeError: Object(...) is not a function ./src/index.js src/index.js:31
28 | firebaseStateName:"firebase" 29 | } 30 | const initialState = {};
28 | firebaseStateName: 'firebase' 29 | } 30 | const initialState = {};
31 | const store = createStore(rootReducer,initialState, 32 |撰写( 33 | applyMiddleware(thunk.withExtraArgument({getFirebase,getFirestore})), 34 | reactReduxFirebase(firebase,config),
31 | const store = createStore(rootReducer,initialState, 32 | compose( 33 | applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })), 34 | reactReduxFirebase(firebase, config),
我尝试使用东西库:
http://docs.react -redux-firebase.com/history/v3.0.0/docs/integrations/thunks.html
但是仍然没有成功:/
在我的index.js文件下面
below my index.js file
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { createStore, applyMiddleware, compose } from 'redux'
import rootReducer from './store/reducers/rootReducer'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import { createFirestoreInstance, reduxFirestore, getFirestore } from 'redux-firestore';
import { ReactReduxFirebaseProvider, reactReduxFirebase, getFirebase } from 'react-redux-firebase';
import fbConfig from './config/fbconfig'
import firebase from 'firebase/app'
import 'firebase/firestore'
import 'firebase/auth'
import 'firebase/storage'
import 'firebase/functions'
firebase.initializeApp(fbConfig);
firebase.firestore();
firebase.storage().ref();
firebase.functions();
const config = {
useFirestoreForProfile:true,
userProfile: 'Klanten',
userFirestoreForProfile: true,
attachAuthIsReady: true,
firebaseStateName: 'firebase'
}
const initialState = {};
const store = createStore(rootReducer,initialState,
compose(
applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
reactReduxFirebase(firebase, config),
reduxFirestore(firebase)
)
)
store.firebaseAuthIsReady.then(() => {
const rrfProps = {
firebase,
config: fbConfig,
dispatch: store.dispatch,
createFirestoreInstance
}
ReactDOM.render(<Provider store={store}><ReactReduxFirebaseProvider {...rrfProps}><App /></ReactReduxFirebaseProvider></Provider>, document.getElementById('root'));
serviceWorker.unregister();
})
这是我的rootReducer.js
this is my rootReducer.js
import authReducer from './authReducer'
import shopReducer from './shopReducer'
import { combineReducers } from 'redux'
import { firebaseReducer } from 'react-redux-firebase'
import { firestoreReducer } from 'redux-firestore'
const rootReducer = combineReducers({
firebase: firebaseReducer,
firestore: firestoreReducer,
auth: authReducer,
shop: shopReducer
})
export default rootReducer
推荐答案
这是您的问题所在:
reactReduxFirebase(firebase, config),
reduxFirestore(firebase)
最新版本中的配置有所更改,如果您使用的是React V6,则必须使用该更改.
There has been a little change in the configuration in the latest version, which you must use if you're using react V6.
*请确保您输入以下命令安装最新版本:
*Make sure you install the latest version by typing:
npm i --save react-redux-firebase@next
http://docs. react-redux-firebase.com/history/v3.0.0/docs/v3-migration-guide.html
+ import { ReactReduxFirebaseProvider } from 'react-redux-firebase'
+ import { createFirestoreInstance } from 'redux-firestore'
- import { reactReduxFirebase } from 'react-redux-firebase' // removed
- import { reduxFirestore } from 'redux-firestore' // removed
const store = createStore(
rootReducer,
initialState,
compose(
- reactReduxFirebase(firebase, rrfConfig), // removed
- reduxFirestore(firebase)
// applyMiddleware(...middleware) // removed
)
)
+ const rrfProps = {
+ firebase,
+ config: rrfConfig,
+ dispatch: store.dispatch,
+ createFirestoreInstance // <- needed if using firestore
+ }
const App = () => (
<Provider store={store}>
+ <ReactReduxFirebaseProvider {...rrfProps}>
<Todos />
+ </ReactReduxFirebaseProvider>
</Provider>
);
这篇关于TypeError:Object(...)不是index.js上的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!