From 98b57181ea6171fdf11c6b2a100063143cf1a276 Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Tue, 19 Apr 2022 12:34:13 -0700 Subject: [PATCH 1/4] feat: allow pass-through script props in ScrollRestoration --- packages/remix-react/components.tsx | 2 +- packages/remix-react/scroll-restoration.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/remix-react/components.tsx b/packages/remix-react/components.tsx index 721e5a49ae3..4d566d8308d 100644 --- a/packages/remix-react/components.tsx +++ b/packages/remix-react/components.tsx @@ -752,7 +752,7 @@ export function Meta() { */ let isHydrated = false; -type ScriptProps = Omit< +export type ScriptProps = Omit< React.HTMLProps, | "children" | "async" diff --git a/packages/remix-react/scroll-restoration.tsx b/packages/remix-react/scroll-restoration.tsx index b517b436233..3b874a51ee0 100644 --- a/packages/remix-react/scroll-restoration.tsx +++ b/packages/remix-react/scroll-restoration.tsx @@ -2,6 +2,7 @@ import * as React from "react"; import { useLocation } from "react-router-dom"; import { useBeforeUnload, useTransition } from "./components"; +import type { ScriptProps } from "./components"; let STORAGE_KEY = "positions"; @@ -20,7 +21,7 @@ if (typeof document !== "undefined") { * * @see https://remix.run/api/remix#scrollrestoration */ -export function ScrollRestoration({ nonce = undefined }: { nonce?: string }) { +export function ScrollRestoration(props: ScriptProps) { useScrollRestoration(); // wait for the browser to restore it on its own @@ -54,7 +55,7 @@ export function ScrollRestoration({ nonce = undefined }: { nonce?: string }) { return (