Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on the transaction page, suggested fix #12

Open
romeo4934 opened this issue Oct 18, 2024 · 0 comments
Open

error on the transaction page, suggested fix #12

romeo4934 opened this issue Oct 18, 2024 · 0 comments

Comments

@romeo4934
Copy link

romeo4934 commented Oct 18, 2024

The error you're encountering is due to the way the redirect is being handled in the TransactionsPage component. In Next.js, you can't return a redirect object directly from a server component. Instead, you should use the redirect function from next/navigation. Let's modify the code to fix this issue:

file: app/transactions/page.tsx

// ... existing imports ...
import { redirect } from 'next/navigation';

// ... existing code ...

export default async function TransactionsPage({ params, searchParams }: { params: {}; searchParams: { page: string } }) {
  // ... existing code ...

  if (page > totalPages) {
    // Redirect to the last valid page if the requested page is out of range
    redirect(`/transactions?page=${totalPages}`);
  }

  // ... rest of the component code ...
}

// ... rest of the file ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant