Skip to content

Commit

Permalink
Suspense boundary for useSearchParams
Browse files Browse the repository at this point in the history
  • Loading branch information
Debilski committed Aug 9, 2024
1 parent 3e0f9f6 commit dcf2362
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 3 additions & 5 deletions app/civiewer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useSearchParams } from 'next/navigation'
import { useSearchParams } from 'next/navigation';
import { useEffect, useState } from "react";


Expand Down Expand Up @@ -45,7 +45,7 @@ export default function CIViewer() {

useEffect(() => {
if (!jsonPage) return;

fetch(jsonPage)
.then(response => response.json())
.then(setData);
Expand All @@ -54,8 +54,6 @@ export default function CIViewer() {
if (!jsonPage) return (<p>No data</p>);

return (
<>
<CITable data={data}></CITable>
</>
<CITable data={data}></CITable>
);
}
7 changes: 4 additions & 3 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Image from "next/image";
import CITable from "./civiewer";
import CIViewer from "./civiewer";
import { Suspense } from 'react';

export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">
<CIViewer></CIViewer>
<Suspense>
<CIViewer></CIViewer>
</Suspense>
</div>
</main>
);
Expand Down

0 comments on commit dcf2362

Please sign in to comment.