Skip to content

RCSStaticRouter Breaks React 18 Compatibility #14036

@benquarmby

Description

@benquarmby

The RSCStaticRouter introduced in #13700 makes use of the React.use() hook. This API does not exist in stable versions of React 18 and is only available in React 19 (reference: React 18 docs).

// @ts-expect-error - need to update the React types
const payload = React.use(getPayload()) as RSCPayload;

The peer dependency range for react declares compatibility with any version greater than or equal to 18:

"peerDependencies": {
"react": ">=18",

This will likely result in runtime problems for apps using React 18. For those bundling with webpack (out of fashion, I know), build time breaks with the following error:

ERROR in ../../node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/react-router/dist/development/chunk-T3VM44WY.mjs 2499:18-28
export 'use' (imported as 'React5') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, startTransition, unstable_act, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, version)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions