Skip to content

Conversation

@SierraTran
Copy link
Contributor

@SierraTran SierraTran commented Oct 28, 2025

Closes: #1123
Closes: #1090

@SierraTran SierraTran linked an issue Oct 28, 2025 that may be closed by this pull request
@SierraTran SierraTran self-assigned this Oct 28, 2025
Copy link
Contributor

@cowsed cowsed left a comment

Choose a reason for hiding this comment

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

This seems to work for reloading the page which is good, but not for switching to different pages
(click on equipment edit, change a text box, press the manage trainings button).

after a little bit of research it looks like you have to use useBlocker to tie into the react router https://reactrouter.com/api/hooks/useBlocker

@SierraTran
Copy link
Contributor Author

SierraTran commented Nov 5, 2025

I'm stuck and running into issues with trying to implement useBlocker (and even usePrompt). The page shows up blank and I get a long, vague "Uncaught Error" in the console.

Just to get the functionality in, I plan on doing some work-around. Once that's settled, I want to investigate more and try to put useBlocker back in.

@SierraTran
Copy link
Contributor Author

SierraTran commented Nov 10, 2025

This seems to work for reloading the page which is good, but not for switching to different pages (click on equipment edit, change a text box, press the manage trainings button).

after a little bit of research it looks like you have to use useBlocker to tie into the react router https://reactrouter.com/api/hooks/useBlocker

So useBlocker doesn't work with <BrowserRouter>, which we have in App.tsx. From what I've read, BrowserRouter doesn't support navigation blocking out of the box.

I'm reluctant to (because I don't want to make any risky changes), but I would have to switch to using createBrowserRouter so navigation blocking can be supported. BrowserRouter isn't considered a Data API but routers made via createBrowserRouter are.

Thoughts, @cowsed ? Should I try to use createBrowserRouter? Or write a hacky work-around instead?

@cowsed
Copy link
Contributor

cowsed commented Nov 10, 2025

Hmmm, from what i can see it looks like createBrowserRouter is the new recommended way of doing things and gives us more features like blocking pages and more.
Theres a couple places that should have useBlocker like behavior that currently don't behave correctly so i think doing the transition to createBrowserRouter makes sense

we just have to make sure we test all the pages especially ones with more complicated url formats

SierraTran and others added 2 commits November 10, 2025 10:48
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.

Changes May Not be saved dialog on the equipment editor page Trainer Route is Unused

3 participants