project_graphql_blog
project_graphql_blog copied to clipboard
Comment doesn't display with correct slug
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!
Thank You!