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

Fix route params overwriting route properties #557

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

marvinhagemeister
Copy link
Member

@marvinhagemeister marvinhagemeister commented Apr 27, 2021

When a query param was named the same as an existing key on the route like "path", we'd overwrite that.

Imagine that we are on /foo/bar as the url and our route looks like this:

<Route path="/foo/:id" ... />
// -> { path: "/foo/bar", query: {}, id: "bar" }

But when we name the param the same as an existing key we'd overwrite those:

<Route path="/:path/:query" ... />
// -> { path: "bar", query: "bar" }

By moving params to their own object we avoid that issue all together. This is also in line with how most other routers in the wild store params.

<Route path="/:path/:query" ... />
// -> { path: "/foo/bar", query: {}, params: { path: "foo", query: "bar" }}

When a query param was named the same as an existing key on the route
like "path", we'd overwrite that. By moving params to their own object
we avoid that issue all together.
@changeset-bot
Copy link

changeset-bot bot commented Apr 27, 2021

🦋 Changeset detected

Latest commit: 8e8690a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-iso Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@marvinhagemeister marvinhagemeister merged commit ca6e40d into main Apr 27, 2021
@marvinhagemeister marvinhagemeister deleted the iso-overwrite-params branch April 27, 2021 07:38
@github-actions github-actions bot mentioned this pull request Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants