Skip to content

Commit

Permalink
[1.x] Fix doubling hash in React StrictMode (#1728)
Browse files Browse the repository at this point in the history
* Fix double hash

* Format by prettier

* re-use hash variable already set

---------

Co-authored-by: Joe Tannenbaum <[email protected]>
  • Loading branch information
TomKalina and joetannenbaum authored Sep 18, 2024
1 parent 2104a1b commit 3723ef4
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions packages/core/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { default as Axios, AxiosResponse } from 'axios'
import debounce from './debounce'
import {
fireBeforeEvent,
fireErrorEvent,
fireExceptionEvent,
fireFinishEvent,
fireInvalidEvent,
fireNavigateEvent,
fireProgressEvent,
fireStartEvent,
fireSuccessEvent,
fireBeforeEvent,
fireErrorEvent,
fireExceptionEvent,
fireFinishEvent,
fireInvalidEvent,
fireNavigateEvent,
fireProgressEvent,
fireStartEvent,
fireSuccessEvent,
} from './events'
import { hasFiles } from './files'
import { objectToFormData } from './formData'
import modal from './modal'
import {
ActiveVisit,
GlobalEvent,
GlobalEventNames,
GlobalEventResult,
LocationVisit,
Page,
PageHandler,
PageResolver,
PendingVisit,
PreserveStateOption,
RequestPayload,
VisitId,
VisitOptions,
ActiveVisit,
GlobalEvent,
GlobalEventNames,
GlobalEventResult,
LocationVisit,
Page,
PageHandler,
PageResolver,
PendingVisit,
PreserveStateOption,
RequestPayload,
VisitId,
VisitOptions,
} from './types'
import { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash } from './url'

Expand Down Expand Up @@ -82,7 +82,10 @@ export class Router {
}

protected handleInitialPageVisit(page: Page): void {
this.page.url += window.location.hash
const hash = window.location.hash
if (!this.page.url.includes(hash)) {
this.page.url += hash
}
this.setPage(page, { preserveState: true }).then(() => fireNavigateEvent(page))
}

Expand Down

0 comments on commit 3723ef4

Please sign in to comment.