project_mern_memories icon indicating copy to clipboard operation
project_mern_memories copied to clipboard

UPDATE action it retrives getPosts before updated post.

Open enrico-bellanti opened this issue 2 years ago • 3 comments

When using UPDATE action it trigger the effect to getPosts but it retrive them before have updated the post. So I got the state changed but the api request "getPosts" get old values. see the screenshot below to understand better the issue.

Immagine 2022-03-02 140246

enrico-bellanti avatar Mar 02 '22 13:03 enrico-bellanti

same problem

meetsmarttechnica avatar May 10 '22 12:05 meetsmarttechnica

use this at home component useEffect(() => { dispatch(getPosts()); }, [currentId,dispatch]);

meetsmarttechnica avatar May 10 '22 12:05 meetsmarttechnica

@meetsmarttechnica that's a great solution , but when we click on the update button , posts gets refreshed, and after pressing the "Make updates " button again the posts gets refreshed, Why so and is there any work around?

bharatpaliwal-169 avatar Jun 17 '22 11:06 bharatpaliwal-169