project_mern_memories
project_mern_memories copied to clipboard
UPDATE action it retrives getPosts before updated post.
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.
same problem
use this at home component useEffect(() => { dispatch(getPosts()); }, [currentId,dispatch]);
@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?