import { useQuery } from '@tanstack/react-query'; import { useParams, useNavigate } from 'react-router-dom'; import { fetchPageHistory } from '../apiTools.jsx'; import { useFixLinks } from '../clientStuff.jsx'; import './Pages.css'; function HistoryView() { const noLoad = useFixLinks(); const { pagenumber, editid } = useParams(); const navigate = useNavigate(); const { isPending, error, data } = useQuery({ // fetch the currrent values queryKey: ['page history', pagenumber], queryFn: () => fetchPageHistory(pagenumber) }) const edits = data; const ready = !(error || isPending); const pageTitle = edits ? edits[0]?.title : "[no title]"; return (

🌳{pagenumber}. {ready ? pageTitle : "..."}


{ ready ?
    { edits.map(({id, number, title, time, author}) =>
  1. {id} : "{title}", {time} by user #{author}
  2. ) }
: (isPending ? "Loading..." : JSON.stringify(error)) }
); } export default HistoryView;