Next.js template
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 754B

12345678910111213141516171819202122232425262728293031
  1. import { dehydrate, QueryClient } from '@tanstack/react-query';
  2. import { signOut } from 'next-auth/react';
  3. import PaginationComponentRQ from '../components/pagination/react-query/PaginationComponentRQ';
  4. import { getData } from '../requests/dataRequest';
  5. const Home = () => {
  6. function logoutHandler() {
  7. signOut();
  8. }
  9. return (
  10. <>
  11. <h1>Home</h1>
  12. <button onClick={logoutHandler}>Logout</button>
  13. <PaginationComponentRQ></PaginationComponentRQ>
  14. </>
  15. );
  16. };
  17. export async function getServerSideProps() {
  18. const queryClient = new QueryClient();
  19. await queryClient.prefetchQuery(['randomData', 1], () => getData(1));
  20. return {
  21. props: {
  22. dehydratedState: dehydrate(queryClient),
  23. },
  24. };
  25. }
  26. export default Home;