Skip to content

Commit 41ad237

Browse files
committed
Wire up support for unstable_transitions flag
1 parent 63cd65a commit 41ad237

File tree

8 files changed

+869
-26
lines changed

8 files changed

+869
-26
lines changed

.changeset/olive-planets-think.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
Add new `unstable_transitions` flag to routers to give users control over the usage of [`React.startTransition`](https://react.dev/reference/react/startTransition) and [`React.useOptimistic`](https://react.dev/reference/react/useOptimistic).
6+
7+
- Framework Mode + Data Mode:
8+
- `<HydratedRouter unstable_transition>`/`<RouterProvider unstable_transition>`
9+
- When left unset (current default behavior), all state updates are wrapped in `React.startTransition`
10+
- ⚠️ This can lead to buggy behaviors if you are wrapping your own navigations/fetchers in `React.startTransition`
11+
- You should set the flag to `true` if you run into this scenario
12+
- When set to `true`, all router navigations and state changes will be wrapped
13+
in `React.startTransition` and router state changes will _also_ be sent through
14+
`React.useOptimistic` to surface mid-navigation router state changes to the UI (i.e., `useNavigation()`)
15+
- When set to `false`, the router will not leverage `React.startTransition` or
16+
`React.useOptimistic` on any navigations or state changes
17+
- Declarative Mode
18+
- `<BrowserRouter unstable_transitions>`
19+
- When left unset, all router state updates are wrapped in `React.startTransition`
20+
- When set to `true`, all router navigations and state updates will be wrapped
21+
in `React.startTransition`
22+
- When set to `false`, the router will not leverage `React.startTransition` on
23+
any navigations or state changes

0 commit comments

Comments
 (0)