-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
v7 - types not being exported by react-router #12431
Comments
Same here, temporarily import "react-router/dist/production" instead of "react-router" to have types. But it breaks running... |
I'm not able to reproduce this. I'm wondering if it's something specific to your |
Hi @brookslybrand , I hope the functions/types below can be exported from react-router as we are using them in our current code. import { History, Listener } from "@remix-run/router/history"; |
These all come from history (a dependency of I'm not sure why we were re-exporting them before/why we stopped now (maybe @brophdawg11 has some context) I'm a little skeptical you need these though if you are already using |
Hey mate, We use it for module federation. I tried importing these features directly from the history package, but it is not included as part of react-router v7 import type { Theme } from "@mui/material";
import type { History, Listener } from "@remix-run/router/history";
import { createMemoryHistory, createBrowserHistory } from "@remix-run/router";
import { createRoot } from "react-dom/client";
import App from "./App";
import { wsClient } from "./config/apollo/wsClient";
import type { User } from "./graphql/graphqlTypes";
export interface IParentProps {
onParentNavigate?: Listener;
defaultHistory: History;
initialPath?: string;
user?: User;
theme?: Theme;
}
const mount = (
elem: any,
{ onParentNavigate, defaultHistory, initialPath, ...rest }: IParentProps
) => {
const childHistory =
defaultHistory ||
createMemoryHistory({
initialEntries: [initialPath!]
});
if (onParentNavigate) {
// update child history when parent history changes
childHistory.listen(onParentNavigate);
}
// reset websocket
wsClient.resetStore();
const root = createRoot(elem);
root.render(<App {...rest} />);
return {
// give parent a handle, when child history changes, update the parent history
onChildNavigate: (currentHistory: History) => {
const nextPathname = currentHistory.location.pathname;
const currentPathname = childHistory.location.pathname;
if (nextPathname !== currentPathname) {
childHistory.push(nextPathname);
}
}
};
};
export { mount };
if (process.env.NODE_ENV === "development") {
const devRoot = document.querySelector("#child-root");
if (devRoot) {
mount(devRoot, {
defaultHistory: createBrowserHistory()
});
}
} |
@kelvin2200 Can you provide a reproduction of your issue? I'm also unable to reproduce it. One potential issue is that the @cjnoname The deep imports from I think we stopped exporting the As for module federation usages, we released the |
Hi @brophdawg11, Thanks for helping to export UNSAFE_ functions. I will read through the documents you shared. |
@brophdawg11 the reproduction is in the code I posted. What I did in the past, was to import I am using react-router in a minimal form, in an implementation with react-relay for render-as-you-fetch patterns and preloading queries. Furthermore, (even though this may be off-topic)... WHY did you guys turn this into a (yet another) framework? |
I'm using React Router as a...
library
Reproduction
System Info
Used Package Manager
yarn
Expected Behavior
I expect to be able to re-export any type that I can infer
Actual Behavior
The text was updated successfully, but these errors were encountered: