0
import ReactDOM from "react-dom/client";
import { Provider } from "react-redux";
import reportWebVitals from "./reportWebVitals";
import AppRouter from "./routers/AppRouter";
import "./App.css";
import configureStore from "./store/configureStore";
import { getBlogsToDatabase } from "./actions/blogAction";
import "./firebase/firebaseConfig";

const root = ReactDOM.createRoot(document.getElementById("root"));

const store = configureStore();

const result = (
  <Provider store={store}>
    <AppRouter />
  </Provider>
);

root.render(<p>Loading...</p>);

store.dispatch(getBlogsToDatabase()).then(() => {
  root.render(result);
});

enter image description here

I'm getting an error when using the promise construct I have seen in some posts that it could be a problem with the NPM version. Thanks in advance for the help.

  • Can you show the rest of the store setup logic? Most likely you don't have the `thunk` middleware added. Note that if you use our official Redux Toolkit package as recommend, it automatically adds the thunk middleware for you: https://redux.js.org/tutorials/fundamentals/part-8-modern-redux – markerikson May 25 '22 at 00:03
  • I added thunk middleware. – Orhan Kalkan May 25 '22 at 00:23
  • Can you please show the actual code for both the store setup, and `getBlogsToDatabase`? One of those two has to be the issue. – markerikson May 25 '22 at 01:56

1 Answers1

0

Sorry, dispatch is not a Promise, you cannot use then() on it