×元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件),但得到:未定义

时间:2019-10-01 23:35:03

标签: reactjs firebase

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, getFirestore } from "redux-firestore";
import { ReactReduxFirebaseProvider, getFirebase } from "react-redux-firebase";
import fsConfig from "./config/fsConfig";
import { firebase } from "firebase/app";

const store = createStore(
  rootReducer,
  compose(
    applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore }))
    //reduxFirestore(fsConfig),
    //reactReduxFirebase(fsConfig)
  )
);

const rrfProps = {
  firebase,
  config: fsConfig,
  dispatch: store.dispatch,
  createFirestoreInstance
};

//error position=>
ReactDOM.render(
  <Provider store={store}>
    <ReactReduxFirebaseProvider {...rrfProps}>
      <App />
    </ReactReduxFirebaseProvider>
  </Provider>,
  document.getElementById("root")
);

serviceWorker.unregister();
  

元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。您可能忘记了从定义文件中导出组件,或者可能混淆了默认导入和命名导入。

1 个答案:

答案 0 :(得分:0)

这对我有用。打开终端,转到项目的根目录,然后使用以下命令更新react-redux-firebase

npm install react-router-redux@next

ReactReduxFirebaseProvider的2.4版本中未实现react-redux-firebase的原因因此导致将其包裹在<App />组件周围的问题。

您想要获得react-redux-firebase的3.0版本。