project_mern_memories
project_mern_memories copied to clipboard
THE POSTS DONT RENDER
The posts refuse to show up even though they are present in the database and the API.
If you are using configureStore instead of createStore because it says in VSCode that createStore is deprecated then probable that is the error. Atleast it was for me. Simply just ignore what VSCode says about createStore and just use it. I hope that helps
Post is present in the database but doesn't show up on the screen.
Try with configureStore instead of createStore
Try with configureStore instead of createStore
Still doesn't work
Have you set the currentId and setCurrentId
Hi @ProHaies. I am almost encountering the same issue - my posts are displayed fine at the time of creation and they even get created in my MongoDB cluster but I don't see anything in my browser console + I get the circular progress spinner when I reload the page (the posts don't get fetched). Any ideas on what the issue might be?
Hi @outterspacem check the currentId if it's placed properly like in the video otherwise I have no idea
@ProHaies update: I solved the issue by making sure useEffect(() is under const dispatch = useDispatch();
The posts refuse to show up even though they are present in the database and the API.
Issue fixed! If you are having issues with Redux createStore() being depreciated, here's how to use configureStore():
- Run on server side console ->
NPM
npm install @reduxjs/toolkit
Yarn
yarn add @reduxjs/toolkit
- Include configureStore() in your client/src/index.js file
import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
// import { createStore, applyMiddleware, compose} from "redux";
// import thunk from "redux-thunk";
import { configureStore } from "@reduxjs/toolkit";
import reducers from "./reducers";
import App from "./App";
import "./index.css";
// const store = createStore(reducers, compose(applyMiddleware(thunk)));
const store = configureStore({ reducer: reducers });
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById("root")
);
Job done!