Unverified Commit e7f55004 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Add router replace to experiment (#37312)



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
parent a7ee8bfd
...@@ -40,7 +40,12 @@ export default function AppRouter({ initialUrl, children }: any) { ...@@ -40,7 +40,12 @@ export default function AppRouter({ initialUrl, children }: any) {
const appRouter = React.useMemo(() => { const appRouter = React.useMemo(() => {
return { return {
prefetch: () => {}, prefetch: () => {},
replace: () => {}, replace: (url: string) => {
previousUrlRef.current = current
setCurrent({ ...current, url })
// TODO: update url eagerly or not?
window.history.replaceState(current, '', url)
},
push: (url: string) => { push: (url: string) => {
previousUrlRef.current = current previousUrlRef.current = current
setCurrent({ ...current, url }) setCurrent({ ...current, url })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment