react-server675fbba4
react-serverfilesexamplesreact-queryappcomments.jsx
examples/react-query/app/comments.jsxjsx646 B1afef80a
"use client";

import "./comments.css";

import { useSuspenseQuery } from "@tanstack/react-query";

import { getComments } from "./get-comments";

export default function Comments() {
  const { data } = useSuspenseQuery({
    queryKey: ["posts-comments"],
    queryFn: getComments,
  });

  return (
    <div className="comments-container">
      {data.map((comment) => (
        <div key={comment.id} className="comment-card">
          <h3 className="comment-name">{comment.name}</h3>
          <p className="comment-email">{comment.email}</p>
          <p className="comment-body">{comment.body}</p>
        </div>
      ))}
    </div>
  );
}