From 2f2cbcb75f2145c248048a795bd51a96660cfd72 Mon Sep 17 00:00:00 2001 From: Nurbol <47626872+Arsikod@users.noreply.github.com> Date: Tue, 11 Oct 2022 12:12:19 +0600 Subject: [PATCH 1/2] Update overview.md --- docs/start/overview.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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: From c184e04d9bd4b5ebb3d02481003bfe313e7bda3c Mon Sep 17 00:00:00 2001 From: Nurbol <47626872+Arsikod@users.noreply.github.com> Date: Tue, 11 Oct 2022 12:15:40 +0600 Subject: [PATCH 2/2] Update contributors.yml --- contributors.yml | 1 + 1 file changed, 1 insertion(+) 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