Repository navigation
component v1.3.0
Minor Changes
-
Customize frame requests and rendering with
defaultResolveFrameand its{ fetch, commit }overrides (#12249)- Previously, adding a custom
resolveFramerequired you to take full control and re-implement core logic from the defaultresolveFrameimplementation defaultResolveFrameprovides the internal default implementation with targetedfetchandcommithooksfetchallows you to override just thefetchcall for the frame (set custom fetch options/headers, implement an in-memory cache, etc.)commitallows you to control the DOM update (trigger a view transition, etc.)resolveFramenow receivesoptions.navigationTypeandoptions.fromdescribing the original navigation for navigation-driven frame reloads, allowing you to differentiate navigation versus imperativeframe.reload()calls- See Resolving Frames for more information and the bookstore demo for example usages
- Previously, adding a custom
-
Follow navigations with the typed
rmx:navigationevent to show pending or optimistic UI. See following a navigation for details. (#12183)// Inside a hydrated component: <button type="submit" mix={on('rmx:navigation', async (event, signal) => { saving = true handle.update() await event.finished.catch(console.error) if (signal.aborted) return saving = false handle.update() })} > {saving ? 'Saving…' : 'Save'} </button>
-
Defer below-the-fold frame requests with
<Frame loading="lazy" fallback={<p>Loading…</p>} />(#12229)- The server renders only the fallback, and the browser loads the frame when it approaches the viewport
- The fallback must be a DOM element to drive the intersection observer; the frame will default to eager loading without a valid fallback element
-
Enhance the frame
reloadStartevent withsrc,method,encType,formData,element,submitter, andfinishedfields for pending and optimistic UI. See following a reload for details. (#12183) -
Multiple selects accept arrays in
valueanddefaultValue. Usevalue={[]}to clear the current selection, ordefaultValue={[]}to initialize a select with no selections. (#12204) -
Pass a DOM anchor element to
prefetch()to use its navigation source and frame target and expose it to custom hooks (#12277) -
Customize prefetching with
defaultPrefetchand its{ fetch, processFrame }overrides (#12277)- Previously, adding a custom
prefetchrequired you to take full control and re-implement core logic from the defaultprefetchimplementation defaultPrefetchprovides the internal default implementation with targetedfetchandprocessFramehooksfetchallows you to override just thefetchcall for the prefetched frame (set custom fetch options/headers, implement an in-memory cache, etc.)processFrameallows you to control subsequent asset prefetching - allowing Remix to discover, but you own control of what gets prefetched and in what order (includes scripts, stylesheets, images, and even nested frames based on theirfallback/loadingbehaviors)- The incoming frame
fragmentallows you to query the inert DOM of the prefetched frame to discover additional assets and implement your own custom prefetching behaviors - See Prefetching for usage
- Previously, adding a custom
-
Reflect locally rendered state in the URL with
updateUrl(href, options?), without fetching, rendering, or changing scroll and focus: (#12110)import { updateUrl } from 'remix/component' let signal = await updateUrl('/products/shirt?color=blue') await updateUrl('/products/shirt?color=red', { history: 'push' })
Patch Changes
-
Fix
clientEntry()failing with "Type instantiation is excessively deep and possibly infinite" when a component's props include aSerializableObject(or anotherSerializableValuetype) alongside a prop that is serializable but not assignable toSerializableObject, such as aFormSubmissionfrom@remix-run/data-schema/experimental/formwith its readonly arrays and records. (#12219) -
The browser runtime loads fewer modules, with no behavior changes. Pages that hydrate with
run()load 23 component modules instead of 35. Apps that only usecreateRoot()orcreateRangeRoot()load 16 instead of 23 and about 6% less gzipped code, and code that only usesclientEntry,css,onandrefloads 9 instead of 13 and about 19% less.updateUrl()andspaResponsenow load only in apps that import them. (#12314) -
Fix a client-rendered
<Frame>remounting with itsfallbackwhen itssrcchanged after its content appeared but while frames or client entries inside it were still loading. Once a frame's content is visible, changingsrcnow always reloads the frame in place, keeping the current content until the new source resolves. (#12274) -
Fix server-rendered
<Frame>content corrupting multibyte characters whenresolveFramereturns a stream whose chunks split a UTF-8 character. The first renderable chunk was decoded twice, and a character cut off at the end of that chunk, or starting in an earlier whitespace-only chunk, was replaced withU+FFFD. Whitespace-only chunks before the first renderable chunk are also no longer dropped. (#12300) -
Pending viewport prefetches pause while the document is hidden and resume with fresh visibility and eligibility checks when it becomes visible. Intent and imperative triggers keep their existing timing. (#12286)
Default prefetching waits for idle time before parsing downloaded HTML and discovering assets. The idle callback has a one-second timeout so busy pages can still make progress; browsers without idle callbacks yield through a timer. Runtime disposal cancels pending viewport work and HTML discovery.
-
Fix focus moving to
<body>when a frame navigation fails, such as a form submission whose response is a 5xx page. The page stays as it was, so focus now stays where the visitor left it. Navigations that succeed still reset focus unless they opt out withdata-rmx-reset-focus="manual"orresetFocus: 'manual'. (#12208) -
Keep text typed and checkboxes or radios toggled before a form control hydrates. Hydration used to overwrite those edits with the server-rendered
valueorchecked, so text typed into a field that streamed in with a frame was lost if its client entry hydrated a moment later. The edit is now kept and replayed asinputandchangeevents once the control's handlers are attached, so app state such as a live search query catches up with what the user sees. (#12294)Replayed events are dispatched by the runtime, so
event.isTrustedisfalse, and handlers run at hydration time rather than in response to a new user action. A handler that submits a form, saves a draft, or starts a request does so as soon as the control hydrates. Values the browser restores into a form, such as Firefox restoring fields on reload or a back/forward navigation that isn't served from the back/forward cache, count as edits too: they are now kept and replayed instead of being reset to the server-rendered values. Addautocomplete="off"to a control to opt it out of browser form restoration. -
Fix list updates that put DOM in the wrong place, removed siblings, or threw: (#12303)
- A keyed
<Fragment>that gains children now inserts them inside the fragment. Before, they were appended after the fragment's later siblings, at the end of the list. - A component that switches from rendering
nullto rendering DOM is now placed correctly when siblings move in the same update, including when it is nested inside a<Fragment>. Before, its DOM could land inside another sibling's fragment. If a sibling after it was removed in the same update,insertBeforethrewNotFoundErrorand the list was left half-updated. - A
<Fragment>at the end of its parent that loses all its children no longer clears the siblings rendered before it.
- A keyed
-
Insert new keyed children once, directly at their final position. Before, a keyed list that gained children while other children kept their places (for example, restoring filtered-out rows) appended each new child to the end of the list and then moved it into place. Custom elements in those rows ran
connectedCallback,disconnectedCallback, andconnectedCallbackagain. (#12301) -
Mixins that listen for
beforeUpdateorcommit, such asanimateLayout()from@remix-run/ui, no longer get quadratically slower as more elements use them. Mounting or removing one used to scan every other mounted mixin with a phase listener, so rendering 20,000 such elements took about 1.4 seconds in Chromium. It now takes about 220 ms and grows linearly with the element count. (#12308) -
Avoid starting a stale frame reload when a
currententrychangelistener starts another navigation while Remix updates the current history entry state. (#12248) -
Keep inherited frame reloads in one lifecycle, without extra
reloadStartevents orreloadCompletebefore rendering finishes. Replaying cached HTML with unchanged frame markers now completes descendant reloads after their content renders. Report streamed child render failures, preserve initial streams on cancellation, and preserve reloads started by synchronous completion or abort listeners. (#12200) -
createScheduler()no longer accepts a thirdstylesargument. The argument was never used: each root takes its style manager from its frame context, so passing one had no effect. Runtime behavior is unchanged, but TypeScript projects that pass three arguments now get a type error ("Expected 2 arguments, but got 3"). Remove the argument to fix it: (#12310)- let scheduler = createScheduler(document, errorTarget, styleManager) + let scheduler = createScheduler(document, errorTarget)
-
Fix a link click, form submission or
navigate()call that interrupts a navigation before its page renders leaving a history entry for the page that never rendered. The new navigation now replaces that entry, so Back returns to the page the visitor saw, including when acurrententrychangelistener starts it before rendering begins. Links and GET forms withdata-rmx-history="replace"also replace the entry before their navigation commits in browsers that support it, as POST forms already did, instead of cancelling the navigation and starting a replacement. (#12240) -
Fix Safari restoring the wrong scroll position on a back or forward navigation whose frames render without waiting on the network, for example when
resolveFramereturns content that is already available. Safari applied the scroll position of the page being left, usually the top, instead of the position saved for the destination. Remix now restores scroll once Safari has moved its history to the destination entry. (#12274) -
Align
<select>initialization across server rendering, client mounting, and hydration with explicit precedence:value, then initialdefaultValue, then optionselected. This resolves previously ambiguous combinations of select and option selection props. (#12204) -
Add a 150ms scroll delay to viewport-driven prefetching, to avoid unnecessary prefetches during scrolls through a list of prefetch-eligible links. Links the visitor stops on are prefetched as before, and links that enter the viewport without a scroll, such as on page load, still prefetch right away. (#12256)