-
Notifications
You must be signed in to change notification settings - Fork 98
Closed
Description
What I am trying to do
I want to load the library and use it with react-router-dom
What I expect to happen
That I can load the library.
What actually happens
vite throws an error because "react-router-dom" is missing
✘ [ERROR] Could not resolve "react-router-dom"
../node_modules/use-query-params/adapters/react-router-6/index.js:2:67:
2 │ import { UNSAFE_NavigationContext, useNavigate, useLocation } from "react-router-dom";
╵ ~~~~~~~~~~~~~~~~~~
You can mark the path "react-router-dom" as external to exclude it from the bundle, which will
remove this error.
main.tsx:
import React from "react";
import "./main.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import { ChakraProvider } from "@chakra-ui/react";
import { BrowserRouter } from "react-router-dom";
import { ColorModeScript } from "@chakra-ui/react";
import Theme from "./Theme";
// @ts-ignore
import { registerSW } from "virtual:pwa-register";
import { createRoot } from "react-dom/client";
// Do not remove this import, it initalizes firebase
import * as Firebase from "./Firebase"; // DO NOT REMOVE
import { QueryParamProvider } from "use-query-params";
import { ReactRouter6Adapter } from "use-query-params/adapters/react-router-6";
const container = document.getElementById("root");
const root = createRoot(container!);
root.render(
<>
<ColorModeScript initialColorMode={Theme.config.initialColorMode} />
<BrowserRouter>
<QueryParamProvider adapter={ReactRouter6Adapter}>
<React.StrictMode>
<ChakraProvider theme={Theme}>
<App />
</ChakraProvider>
</React.StrictMode>
</QueryParamProvider>
</BrowserRouter>
</>
);
reportWebVitals();
const updateSW = registerSW();
Additional information
- my react-router-dom version: v6.6.1
Metadata
Metadata
Assignees
Labels
No labels