嗨,我正在使用React Redux和Firebase数据库制作一个图库。
我遇到这个错误..
“错误:目标容器不是DOM元素”
谁能帮我解决这个问题?
import React from "react";
import ReactDOM from 'react-dom';
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import { createStore, compose, applyMiddleware } from "redux";
import rootReducer from "./components/redux/reducer";
import { Provider } from "react-redux";
import { BrowserRouter } from "react-router-dom";
import "bootstrap/dist/css/bootstrap.min.css";
import thunk from "redux-thunk";
const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(rootReducer, composeEnhancer(applyMiddleware(thunk)));
ReactDOM.render(
<Provider store={store}>
<BrowserRouter>
<App />
</BrowserRouter>
</Provider>,
document.getElementById("root")
);
答案 0 :(得分:0)
问题很可能是在创建#root
元素之前执行了脚本。将脚本标记移动到html中的#root
元素之后,或在“ DOMContentLoaded”事件的回调中执行ReactDOM.render
。