adrianhajdin / project_graphql_blog

With featured and recent posts, categories. full markdown articles, author information, comments, and much more, this fully responsive CMS Blog App is the best Blog Application that you can currently find on YouTube. And what's best of all is that you and your clients can manage the blog from a dedicated Content Management System.
https://jsmastery.pro
1.47k stars 347 forks source link

Comment doesn't display with correct slug #17

Open tuankietcoderr opened 2 years ago

tuankietcoderr commented 2 years ago

In components/Comments.jsx line 14: If we don't add slug to [], the comments won't display until we refresh the page. Solution: add slug to [] like this: from

 useEffect(() => {
    getComments(slug).then((result) => {
      setComments(result);
    });
  }, []);

to

 useEffect(() => {
    getComments(slug).then((result) => {
      setComments(result);
    });
  }, [slug]);

Hope this will behelpful!

mateen993 commented 2 years ago

Thank You!