答案 0 :(得分:0)
您的问题似乎是您没有正确导入react-redux-firebase
或正在使用其回溯版本。您的第二条评论
Error: Context from react-redux not found. If you are using react-redux v6 a v3.*.* version of react-redux-firebase is required.
很明显,可能未安装正确的版本。一种可能的解决方案是使用以下npm命令降级您的React版本并响应redux firebase:
npm -i --save react-redux@5.1.1
npm -i --save react-redux-firebase@2.2.4
这些版本稳定且更好,因为当使用npm
安装常规方式时,React Redux Firebase版本3. *不稳定并且不能自动下载React Redux版本6. *。使用npm i --save react-redux-firebase@latest
降级后,请使用npm start
重新启动应用程序以查看更改。
答案 1 :(得分:0)
将react-redux-firebase升级到v3后,您必须在根文件index.js中进行这些更改
...
import { createFirestoreInstance } from 'redux-firestore';
import { ReactReduxFirebaseProvider } from 'react-redux-firebase';
const firebaseConfig = {
apiKey: "apiKey",
authDomain: "authDomain",
databaseURL: "databaseURL",
projectId: "projectId",
storageBucket: "storageBucket",
messagingSenderId: "messagingSenderId"
};
firebase.initializeApp(firebaseConfig);
firebase.firestore();
const store = createStore(rootReducer,
compose(
applyMiddleware(
thunk.withExtraArgument({ getFirebase, getFirestore })
),
reduxFirestore(firebase),
)
);
const config = { useFirestoreForProfile: true, userProfile: 'users', attachAuthIsReady: true };
const rrfProps = {
firebase,
config,
dispatch: store.dispatch,
createFirestoreInstance
}
const app = (
<Provider store={store}>
<ReactReduxFirebaseProvider {...rrfProps}>
<MuiThemeProvider theme={theme}>
<BrowserRouter>
<App />
</BrowserRouter>
</MuiThemeProvider>
</ReactReduxFirebaseProvider>
</Provider>
)
ReactDOM.render(app, document.getElementById('root'));