project_mern_memories icon indicating copy to clipboard operation
project_mern_memories copied to clipboard

THE POSTS DONT RENDER

Open Nathan-Eyo opened this issue 2 years ago • 9 comments

The posts refuse to show up even though they are present in the database and the API.

Nathan-Eyo avatar Oct 23 '22 15:10 Nathan-Eyo

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

ghost avatar Nov 27 '22 11:11 ghost

errorPostnotShowing Post is present in the database but doesn't show up on the screen.

FALAK097 avatar Dec 21 '22 12:12 FALAK097

Try with configureStore instead of createStore

ghost avatar Dec 21 '22 12:12 ghost

Try with configureStore instead of createStore

Still doesn't work

FALAK097 avatar Dec 22 '22 19:12 FALAK097

Have you set the currentId and setCurrentId

ghost avatar Dec 22 '22 21:12 ghost

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?

outterspacem avatar Dec 29 '22 14:12 outterspacem

Hi @outterspacem check the currentId if it's placed properly like in the video otherwise I have no idea

ghost avatar Dec 29 '22 18:12 ghost

@ProHaies update: I solved the issue by making sure useEffect(() is under const dispatch = useDispatch();

outterspacem avatar Dec 29 '22 18:12 outterspacem

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():

  1. Run on server side console ->

NPM

npm install @reduxjs/toolkit

Yarn

yarn add @reduxjs/toolkit

  1. 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!

Screenshot 2023-12-25 at 10 11 16

Screenshot 2023-12-25 at 10 11 43

AAdewunmi avatar Dec 25 '23 10:12 AAdewunmi