diff --git a/.changeset/late-files-trade.md b/.changeset/late-files-trade.md new file mode 100644 index 00000000000..275b9a21d78 --- /dev/null +++ b/.changeset/late-files-trade.md @@ -0,0 +1,5 @@ +--- +"@remix-run/react": patch +--- + +Allow pass-through props to be passed to the script rendered by `ScrollRestoration` diff --git a/packages/remix-react/__tests__/scroll-restoration-test.tsx b/packages/remix-react/__tests__/scroll-restoration-test.tsx new file mode 100644 index 00000000000..bc4ae14d182 --- /dev/null +++ b/packages/remix-react/__tests__/scroll-restoration-test.tsx @@ -0,0 +1,104 @@ +import * as React from "react"; +import { MemoryRouter, Outlet } from "react-router-dom"; +import { render, screen } from "@testing-library/react"; + +import { LiveReload, RemixEntryContext, Scripts } from "../components"; +import type { RemixEntryContextType } from "../components"; +import { ScrollRestoration } from "../scroll-restoration"; + +import "@testing-library/jest-dom/extend-expect"; + +function AppShell({ children }: { children: React.ReactNode }) { + return ( + + + {children} + + + + ); +} + +describe("", () => { + function withContext(stuff: JSX.Element) { + let context: RemixEntryContextType = { + routeModules: { idk: { default: () => null } }, + manifest: { + routes: { + idk: { + hasLoader: true, + hasAction: false, + hasCatchBoundary: false, + hasErrorBoundary: false, + id: "idk", + module: "idk", + }, + }, + entry: { imports: [], module: "" }, + url: "", + version: "", + }, + matches: [], + clientRoutes: [ + { + id: "idk", + path: "idk", + hasLoader: true, + element: "", + module: "", + async action() { + return {}; + }, + async loader() { + return {}; + }, + }, + ], + routeData: {}, + appState: {} as any, + transitionManager: { + getState() { + return { + transition: {}, + }; + }, + } as any, + }; + return ( + + {stuff} + + ); + } + + it("should render a