Skip to content

[Docs]: Incorrect param name in loader example under "1. Create a Router" section #13680

@Willvillegas

Description

@Willvillegas

Describe what's incorrect/missing in the documentation

In the file react-router/docs/start/data/custom.md, under the section titled ### 1. Create a Router, there's an example that defines a route with the path "shows/:showId". However, inside the loader function, the code incorrectly uses params.id instead of params.showId.

Current code:

loader: ({ request, params }) =>
  fetch(`/api/show/${params.id}.json`, {
    signal: request.signal,
  }),

Correct code:

loader: ({ request, params }) =>
  fetch(`/api/show/${params.showId}.json`, {
    signal: request.signal,
  }),

The dynamic segment in the path is :showId, so params.showId should be used to retrieve its value. params.id would be undefined in this case.

Page

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions