diff --git a/contributors.yml b/contributors.yml index 14beceade9..1b184456e2 100644 --- a/contributors.yml +++ b/contributors.yml @@ -126,3 +126,4 @@ - xavier-lc - xcsnowcity - yuleicul +- Arsikod diff --git a/docs/start/overview.md b/docs/start/overview.md index 4c89724d63..a980d31724 100644 --- a/docs/start/overview.md +++ b/docs/start/overview.md @@ -693,6 +693,36 @@ React Router is built on web standard APIs. [Loaders][loader] and [actions][acti When you get better at React Router, you get better at the web platform. +## Using history outside React component + +Similar to React Router v5 history instance can be used outside of the component. + +Main difference is that in v6+ `history` needs to be installed separately. + +```jsx +npm install history +``` + +Then the whole app needs to be wrapped by `unstable_HistoryRouter` imported from `react-router-dom`. + +Inside index file: + +```tsx +import { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom'; +import { createBrowserHistory } from 'history'; + +export const history = createBrowserHistory(); + +const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); +root.render( + + + + + +); +``` + ## Search Params TODO: