gpt4 book ai didi

javascript - TypeError : Object(. ..) 不是一个函数 - 我迷路了

转载 作者:行者123 更新时间:2023-11-28 03:20:40 24 4
gpt4 key购买 nike

INDEX.JS FILE

import { compose, createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import firebase from '../Firebase/Firebase';
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase';
import { reduxFirestore, getFirestore } from 'redux-firestore';

import rootReducer from './reducers';

// react-redux-firebase config
const rrfConfig = {
userProfile: 'users',
useFirestoreForProfile: true, // Firestore for Profile instead of Realtime DB
};

const composeEnhancers =
process.env.NODE_ENV === 'development'
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
: compose;

const store = createStore(
rootReducer,
composeEnhancers(
reactReduxFirebase(firebase, rrfConfig),
reduxFirestore(firebase),
applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore }))
)
);
export default store;

我相信我的格式是正确的,但是我迷失了。有人可以帮忙吗?以下是我的 reducer 文件夹中的两个文件。请随时提出您可能有的任何问题,我会尽力回答。我严重陷入困境。

<小时/>
REDUCERS -> AUTHREDUCER.JS

const initialState = {

}

export default(state = initialState, action) => {
return'dhdhdhd';
};
<小时/>
REDUCERS -> INDEX.JS

import {combineReducers} from 'redux';
import { firebaseReducer } from 'react-redux-firebase';

import authReducer from './authReducer';

export default combineReducers({
auth: authReducer,
firebase: firebaseReducer,
});`enter code here`

运行 NPM start 时,我返回此错误:

"TypeError: Object(...) is not a function" at const store = createStore( .

最佳答案

结帐https://redux.js.org/api/createstore ,我相信第二个参数应该是初始状态

const initialState = {} // the initial value for your state

const store = createStore(
rootReducer,
initialState, // 2nd argument of createStore is initial state
composeEnhancers(
...
)
);

更新:

结帐http://docs.react-redux-firebase.com/history/v3.0.0/docs/v3-migration-guide.html#remove-store-enhancer因为他们已经弃用了 React-redux-firebase 的增强器

所以

  • 从增强器中删除reactReduxFirebase
  • 使用ReactReduxFirebaseProvider
const rrfProps = {
...
};
const App = () => (
<Provider store={store}>
<ReactReduxFirebaseProvider {...rrfConfig}>
...
</ReactReduxFirebaseProvider>
</Provider>
);

关于javascript - TypeError : Object(. ..) 不是一个函数 - 我迷路了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59185873/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com