Skip to content

Update RouterProvider.md for include some docs for flushSync prop #13576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@
- valerii15298
- ValiantCat
- vdusart
- vezaynk
- VictorElHajj
- vijaypushkin
- vikingviolinist
Expand All @@ -388,3 +389,4 @@
- yuleicul
- zeromask1337
- zheng-chuang

34 changes: 33 additions & 1 deletion docs/api/data-routers/RouterProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,39 @@ createRoot(document.getElementById("root")).render(

[modes: data]

_No documentation_
Provides `flushSync` implementation required for using the `flushSync` option in navigation functions provided by [`useNavigate`](/api/hooks/useNavigate#signature) and [`useSearchParams`](/api/hooks/useSearchParams#setsearchparams-function).

```tsx
import {
RouterProvider,
createBrowserRouter,
} from "react-router";
import { flushSync } from 'react-dom'
import { createRoot } from "react-dom/client";
let router = createBrowserRouter();
createRoot(document.getElementById("root")).render(
<RouterProvider
router={router}
flushSync={(fn) => {
flushSync(fn);
}}
/>
);
```

This prop is provided automatically if the `RouterProvider` is imported from the `react-router/dom` package.

```tsx
import {
createBrowserRouter,
} from "react-router";
import { RouterProvider } from "react-router/dom";
import { createRoot } from "react-dom/client";
let router = createBrowserRouter();
createRoot(document.getElementById("root")).render(
<RouterProvider router={router} />
);
```

### router

Expand Down