File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
packages/react-router/lib Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " react-router " : patch
3+ ---
4+
5+ Use a stable useOptimistic setter stub in React 18
Original file line number Diff line number Diff line change @@ -77,8 +77,8 @@ import { warnOnce } from "./server-runtime/warnings";
7777import type { unstable_ClientInstrumentation } from "./router/instrumentation" ;
7878
7979/**
80- * Webpack can fail to compile on against react versions without this export
81- * complains that `startTransition ` doesn't exist in `React`.
80+ * Webpack can fail to compile against react versions without this export -
81+ * it complains that `useOptimistic ` doesn't exist in `React`.
8282 *
8383 * Using the string constant directly at runtime fixes the webpack build issue
8484 * but can result in terser stripping the actual call at minification time.
@@ -90,6 +90,7 @@ import type { unstable_ClientInstrumentation } from "./router/instrumentation";
9090const USE_OPTIMISTIC = "useOptimistic" ;
9191// @ts -expect-error Needs React 19 types but we develop against 18
9292const useOptimisticImpl = React [ USE_OPTIMISTIC ] ;
93+ const stableUseOptimisticSetter = ( ) => undefined ;
9394
9495function useOptimisticSafe < T > (
9596 val : T ,
@@ -98,7 +99,7 @@ function useOptimisticSafe<T>(
9899 // eslint-disable-next-line react-hooks/rules-of-hooks
99100 return useOptimisticImpl ( val ) ;
100101 } else {
101- return [ val , ( ) => undefined ] ;
102+ return [ val , stableUseOptimisticSetter ] ;
102103 }
103104}
104105
You can’t perform that action at this time.
0 commit comments