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

Chapter 11; 4. Updating the table wrong type #667

Open
sk8higher opened this issue May 7, 2024 · 0 comments
Open

Chapter 11; 4. Updating the table wrong type #667

sk8higher opened this issue May 7, 2024 · 0 comments

Comments

@sk8higher
Copy link

sk8higher commented May 7, 2024

export default async function Page({
  searchParams,
}: {
  searchParams?: {
    query?: string;
    page?: string;
  };
}) {
  const query = searchParams?.query || '';
  const currentPage = Number(searchParams?.page) || 1;

This code gives an error here:
<Table query={query} currentPage={currentPage} />

Type 'string | number' is not assignable to type 'number'.
  Type 'string' is not assignable to type 'number'.ts(2322)
table.tsx(12, 3): The expected type comes from property 'currentPage' which is declared here on type 'IntrinsicAttributes & { query: string; currentPage: number; }'

After changing page prop type to number it works

searchParams?: { query?: string; page?: number };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant