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

docs: Improve Accuracy and Type Safety on Data Fetching Examples #73122

Merged
merged 6 commits into from
Nov 25, 2024

Conversation

hyungjikim
Copy link
Contributor

@hyungjikim hyungjikim commented Nov 23, 2024

Hi, Team.

Updated Reusing data across multiple functions examples on data fetching documentation to improve type safety and accuracy.

Summary of Changes

  1. Added Async Params

  2. Fixed Dynamic Route Example Path

  • Corrected the path structure for dynamic routes to reflect actual usage as app/page.tsx cannot be used to access dynamic routed paths.
  1. Improved Type Safety in generateStaticParams
  • Type mismatch: generateStaticParams expects string parameter, but examples used post.id which of type is number, causing both build time and client run time failures.
image image
  1. Replaced let variable with const variable
  • Prevent accidental reassignment as it is not needed

@ijjk ijjk added the Documentation Related to Next.js' official documentation. label Nov 23, 2024
@ijjk
Copy link
Member

ijjk commented Nov 23, 2024

Allow CI Workflow Run

  • approve CI run for commit: ad59fa0

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@ijjk
Copy link
Member

ijjk commented Nov 23, 2024

Allow CI Workflow Run

  • approve CI run for commit: 0fd09a3

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@hyungjikim hyungjikim changed the title Improve Type Safety on Data Fetching Docs Examples docs: Improve Accuracy and Type Safety on Data Fetching Examples Nov 23, 2024
@ijjk ijjk enabled auto-merge (squash) November 25, 2024 23:49
@ijjk ijjk merged commit 7e87edd into vercel:canary Nov 25, 2024
39 checks passed
wyattjoh pushed a commit that referenced this pull request Nov 28, 2024
)

Hi, Team.

Updated Reusing data across multiple functions examples on data fetching
documentation to improve type safety and accuracy.

### Summary of Changes

1. Added Async Params


2. Fixed Dynamic Route Example Path
- Corrected the path structure for dynamic routes to reflect actual
usage as `app/page.tsx` cannot be used to access dynamic routed paths.


3. Improved Type Safety in `generateStaticParams`
- Type mismatch: `generateStaticParams` expects string parameter, but
examples used `post.id` which of type is number, causing both build time
and client run time failures.

<img width="1109" alt="image"
src="https://github.com/user-attachments/assets/ae6fad44-0b7f-4aac-ac31-74a6581c995b">

<img width="714" alt="image"
src="https://github.com/user-attachments/assets/d8fb19c9-9dd1-4e6a-8d2b-b25f719e3742">


4. Replaced let variable with const variable
- Prevent accidental reassignment as it is not needed

---------

Co-authored-by: JJ Kasper <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Related to Next.js' official documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants