Skip to content

Router bug fixes#31

Merged
thepassle merged 1 commit into
thepassle:masterfrom
nj-reve:nj/router-bug-fixes
May 13, 2025
Merged

Router bug fixes#31
thepassle merged 1 commit into
thepassle:masterfrom
nj-reve:nj/router-bug-fixes

Conversation

@nj-reve
Copy link
Copy Markdown
Contributor

@nj-reve nj-reve commented May 12, 2025

Hi - when using the router we ran into a few issues that should be fixed by this PR:

  • Fix type of shouldNavigate() to allow for it to be async (the code already supports this)
  • Fix type of condition to properly allow for both sync and async boolean returns (missing parens around the sync case)
  • Make multiple redirects work properly by switching to the new route's plugins after a redirect (in the original code, reassigning the plugins array doesn't actually change the array used by the for loop)

Thanks!

* Fix type of `shouldNavigate()` to allow for it to be async (the code already supports this)
* Fix type of `condition` to properly allow for both sync and async boolean returns (missing parens around the sync case)
* Make multiple redirects work properly by switching to the new route's plugins after a redirect
  (in the original code, reassigning the `plugins` array doesn't actually change the array used by the for loop)
Comment thread router/types.ts
redirect: string,
condition: () => boolean | (() => Promise<Boolean>),
};
shouldNavigate?: ((context: Context) => ShouldNavigateResult) | ((context: Context) => Promise<ShouldNavigateResult>);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also have just been (context: Context) => ShouldNavigateResult | Promise<ShouldNavigateResult> but I was following the existing pattern from condition.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like #30

@thepassle thepassle merged commit c29f167 into thepassle:master May 13, 2025
@thepassle
Copy link
Copy Markdown
Owner

Thank you! This was published in @thepassle/app-tools@0.9.13

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.

3 participants