@@ -10,7 +10,7 @@ import {
1010 type RouterState ,
1111} from "../../router" ;
1212
13- import type { RemixContextObject } from "./entry" ;
13+ import type { FrameworkContextObject } from "./entry" ;
1414import invariant from "./invariant" ;
1515import {
1616 getKeyedLinksForMatches ,
@@ -53,16 +53,19 @@ function useDataRouterStateContext() {
5353}
5454
5555////////////////////////////////////////////////////////////////////////////////
56- // RemixContext
56+ // FrameworkContext
5757
58- export const RemixContext = React . createContext < RemixContextObject | undefined > (
59- undefined
60- ) ;
61- RemixContext . displayName = "Remix " ;
58+ export const FrameworkContext = React . createContext <
59+ FrameworkContextObject | undefined
60+ > ( undefined ) ;
61+ FrameworkContext . displayName = "FrameworkContext " ;
6262
63- export function useRemixContext ( ) : RemixContextObject {
64- let context = React . useContext ( RemixContext ) ;
65- invariant ( context , "You must render this element inside a <Remix> element" ) ;
63+ export function useFrameworkContext ( ) : FrameworkContextObject {
64+ let context = React . useContext ( FrameworkContext ) ;
65+ invariant (
66+ context ,
67+ "You must render this element inside a <HydratedRouter> element"
68+ ) ;
6669 return context ;
6770}
6871
@@ -91,7 +94,7 @@ export function usePrefetchBehavior<T extends HTMLAnchorElement>(
9194 prefetch : PrefetchBehavior ,
9295 theirElementProps : PrefetchHandlers
9396) : [ boolean , React . RefObject < T > , PrefetchHandlers ] {
94- let remixContext = React . useContext ( RemixContext ) ;
97+ let frameworkContext = React . useContext ( FrameworkContext ) ;
9598 let [ maybePrefetch , setMaybePrefetch ] = React . useState ( false ) ;
9699 let [ shouldPrefetch , setShouldPrefetch ] = React . useState ( false ) ;
97100 let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } =
@@ -139,8 +142,8 @@ export function usePrefetchBehavior<T extends HTMLAnchorElement>(
139142 setShouldPrefetch ( false ) ;
140143 } ;
141144
142- // No prefetching if not using Remix-style SSR
143- if ( ! remixContext ) {
145+ // No prefetching if not using SSR
146+ if ( ! frameworkContext ) {
144147 return [ false , ref , { } ] ;
145148 }
146149
@@ -219,7 +222,8 @@ function getActiveMatches(
219222 @category Components
220223 */
221224export function Links ( ) {
222- let { isSpaMode, manifest, routeModules, criticalCss } = useRemixContext ( ) ;
225+ let { isSpaMode, manifest, routeModules, criticalCss } =
226+ useFrameworkContext ( ) ;
223227 let { errors, matches : routerMatches } = useDataRouterStateContext ( ) ;
224228
225229 let matches = getActiveMatches ( routerMatches , errors , isSpaMode ) ;
@@ -279,7 +283,7 @@ export function PrefetchPageLinks({
279283}
280284
281285function useKeyedPrefetchLinks ( matches : AgnosticDataRouteMatch [ ] ) {
282- let { manifest, routeModules } = useRemixContext ( ) ;
286+ let { manifest, routeModules } = useFrameworkContext ( ) ;
283287
284288 let [ keyedPrefetchLinks , setKeyedPrefetchLinks ] = React . useState <
285289 KeyedHtmlLinkDescriptor [ ]
@@ -312,7 +316,7 @@ function PrefetchPageLinksImpl({
312316 matches : AgnosticDataRouteMatch [ ] ;
313317} ) {
314318 let location = useLocation ( ) ;
315- let { manifest, routeModules } = useRemixContext ( ) ;
319+ let { manifest, routeModules } = useFrameworkContext ( ) ;
316320 let { matches } = useDataRouterStateContext ( ) ;
317321
318322 let newMatchesForData = React . useMemo (
@@ -412,7 +416,7 @@ function PrefetchPageLinksImpl({
412416 @category Components
413417 */
414418export function Meta ( ) {
415- let { isSpaMode, routeModules } = useRemixContext ( ) ;
419+ let { isSpaMode, routeModules } = useFrameworkContext ( ) ;
416420 let {
417421 errors,
418422 matches : routerMatches ,
@@ -545,7 +549,7 @@ function isValidMetaTag(tagName: unknown): tagName is "meta" | "link" {
545549}
546550
547551/**
548- * Tracks whether Remix has finished hydrating or not , so scripts can be skipped
552+ * Tracks whether hydration is finished, so scripts can be skipped
549553 * during client-side updates.
550554 */
551555let isHydrated = false ;
@@ -596,7 +600,7 @@ export type ScriptsProps = Omit<
596600 */
597601export function Scripts ( props : ScriptsProps ) {
598602 let { manifest, serverHandoffString, isSpaMode, renderMeta } =
599- useRemixContext ( ) ;
603+ useFrameworkContext ( ) ;
600604 let { router, static : isStatic , staticContext } = useDataRouterContext ( ) ;
601605 let { matches : routerMatches } = useDataRouterStateContext ( ) ;
602606 let navigation = useNavigation ( ) ;
0 commit comments