【发布时间】:2021-03-02 08:17:35
【问题描述】:
我正在转移到 react-redux-firebase 3.x 我正在学习本教程的反应。 https://github.com/ayush221b/MarioPlan-react-redux-firebase-app
我应该如何迁移以下代码?
index.js
const store = createStore(rootReducer,
compose(
applyMiddleware(thunk.withExtraArgument({getFirebase,getFirestore})),
reduxFirestore(fbConfig),
reactReduxFirebase(fbConfig, {useFirestoreForProfile: true, userProfile: 'users', attachAuthIsReady: true})
)
);
我找到了这份文件。 https://react-redux-firebase.com/docs/v3-migration-guide.html 我在引用时重建项目。 但是,我遇到了一些问题。 我不知道这个火力基地是从哪里来的。 fffConfig 是常见的 firebase-config 吗?
reactReduxFirebase(firebase, rrfConfig)
fbconfig.js
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "1:12345:web:12345",
measurementId: "G-6MGBT"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.firestore();
export default firebase;
https://github.com/ayush221b/MarioPlan-react-redux-firebase-app/blob/master/src/index.js
我修改的代码
const rrfConfig = {
userProfile: 'users',
useFirestoreForProfile: true, // Firestore for Profile instead of Realtime DB
attachAuthIsReady: true
}
const rrfProps = {
fbConfig,
config: rrfConfig,
dispatch: store.dispatch,
createFirestoreInstance // <- needed if using firestore
}
ReactDOM.render(
<React.StrictMode>
<Provider store = {store}>
<ReactReduxFirebaseProvider {...rrfProps}>
<App />
</ReactReduxFirebaseProvider>
</Provider>
</React.StrictMode>
,document.getElementById('root')
错误
TypeError: Cannot read property '_' of undefined
createFirebaseInstance
src/createFirebaseInstance.js:38
35 | }
36 |
37 | // Add internal variables to firebase instance
> 38 | const defaultInternals = {
| ^ 39 | watchers: {},
40 | listeners: {},
41 | callbacks: {},
【问题讨论】:
-
您好,您遇到的错误是在您的代码的第 38 行中抛出的,我们看不到您发布的代码与哪个代码相对应。但也许 this article 解释你的错误对调试你的代码很有用。
标签: firebase google-cloud-firestore react-redux-firebase