Skip to content

[Feature]: generatePath should extract its required parameters from the URL #9098

@macarie

Description

@macarie

What is the new or updated feature that you are suggesting?

I think generatePath should extract its required parameters from the URL.

I found this "issue" when migrating from v5 to v6, thus removing @types/react-router-dom from the dev dependencies.

The generatePath signature from DefinitelyTyped (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/index.d.ts#L169) extracts the required parameters from the URL, while the official version (https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router.ts#L103 or https://github.com/remix-run/react-router/blob/dev/packages/router/utils.ts#L478?) does not.

IIRC, in v6, it should be easier to write the "extractor" as only required parameters and the * at the end are allowed.

Are there any reasons behind this divergence?

Why should this feature be included?

I've found that feature helpful, especially when building URLs from consts in different components/files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestUsed to close PRs that haven't gone through/been accepted the Proposal process yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions