Skip to content

Commit

Permalink
fix: Patch missing route props on _props copy (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
willybrauner authored Oct 13, 2024
1 parent f080af7 commit 90935b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .changeset/sour-beans-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@wbe/low-router-preact": minor
---

Patch missing route props on \_props copy

reference to #56

In case the route didn't had a specific props object, `_props` was `undefined`, and last `route.props` of the same route was registered in `route._props` object. To avoid this behavior, we set an empty object on `props.route` if no props exist on the initial route object.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export const routes = [
{
path: "/work/:id",
name: "work",
props: {
color: "red",
},
action: () => WorkPage,
getStaticProps: async (context, locale) => {
if (import.meta.env.SSR) {
Expand Down
2 changes: 1 addition & 1 deletion packages/low-router-preact/src/components/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function LowReactRouter(props: {

// save props stored on the route object before mute it
// if it had been already saved, return it
context.route._props = context.route._props || context.route.props
context.route._props = context.route._props || context.route.props || {}

// Request get static props
// update props with saved route._props
Expand Down

0 comments on commit 90935b1

Please sign in to comment.