5- Accessing Query String Parameters: Updated code for query string

Here is the updated code for page.tsx if you are following along in the “Mastering Next.js 13 with TypeScript/Routing and Navigation (50m)/5- Accessing Query String Parameters (7:08)” lesson.

import React from "react";

interface Props {
  params: Promise<{ slug: string[] }>;
  searchParams: Promise<{ sortOrder: string }>;
}

const ProductPage = async (props: Props) => {
  const params = await props.params;
  const searchParams = await props.searchParams;

  const { slug } = params;
  const { sortOrder } = searchParams;

  return (
    <div>
      ProductPage {slug} {sortOrder}
    </div>
  );
};

export default ProductPage;
1 Like