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

Problems when building with vite 6.x.x #137

Open
steinarb opened this issue Jan 23, 2025 · 1 comment
Open

Problems when building with vite 6.x.x #137

steinarb opened this issue Jan 23, 2025 · 1 comment

Comments

@steinarb
Copy link

Starting with vite 6.0.0 my applications using redux-first-history 5.2.0 get the following stack trace on startup:

chunk-K6AXKMTT.mjs:182 Uncaught Error: useRoutes() may be used only in the context of a <Router> component.
    at invariant (chunk-K6AXKMTT.mjs:182:11)
    at useRoutesImpl (chunk-K6AXKMTT.mjs:4200:3)
    at useRoutes (chunk-K6AXKMTT.mjs:4197:10)
    at Routes (chunk-K6AXKMTT.mjs:5045:10)
    at renderWithHooks (react-dom-client.production.js:3681:21)
    at updateFunctionComponent (react-dom-client.production.js:5637:15)
    at beginWork (react-dom-client.production.js:6666:14)
    at performUnitOfWork (react-dom-client.production.js:10860:14)
    at workLoopSync (react-dom-client.production.js:10743:37)
    at renderRootSync (react-dom-client.production.js:10724:20)

When building with the last v5 vite (5.4.14 at the time of writing), the application starts up normally.

Googling the error message gives me matches like this https://stackoverflow.com/a/69796015 (that the router is missing)
So maybe (just a guess), with vite 6.x.x HistoryRouter is no longer recognized as a router...?

@steinarb
Copy link
Author

I have pushed a repro on https://github.com/steinarb/handlereg/tree/redux-first-history-issue-137

To run it you need java sdk and maven installed:

  1. Clone and build
    mkdir -p ~/git
    cd ~/git
    git clone https://github.com/steinarb/handlereg.git
    git checkout redux-first-history-137
    mvn install
    
  2. Download apache karaf and follow the instructions of "start the server" https://karaf.apache.org/manual/latest/quick-start.html
  3. From the karaf command line install the app
    feature:repo-add mvn:no.priv.bang.handlereg/karaf/LATEST/xml/features
    feature:install handlereg-with-derby
    
  4. Open http://localhost:8181/handlereg to see the error

The frontend is here in the code: https://github.com/steinarb/handlereg/tree/redux-first-history-issue-137/handlereg.web.frontend/src/main/frontend

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

No branches or pull requests

1 participant