diff --git a/CHANGELOG.md b/CHANGELOG.md index 6afa7bc..597ecd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,13 @@ * **core:** xstate v5 support ([4c7a57a](https://github.com/koordinates/xstate-tree/commit/4c7a57ad5842a76aa2a33360f3a81c04eb66ca72)), closes [#58](https://github.com/koordinates/xstate-tree/issues/58) +## [4.6.1](https://github.com/koordinates/xstate-tree/compare/v4.6.0...v4.6.1) (2024-01-25) + + +### fix + +* **routing:** flakey onloadEvent detection ([43f17c6](https://github.com/koordinates/xstate-tree/commit/43f17c67c60f566164ba7dcaa010719139183973)) + # [4.6.0](https://github.com/koordinates/xstate-tree/compare/v4.5.0...v4.6.0) (2024-01-23) diff --git a/src/utils.ts b/src/utils.ts index 4727eea..ea5512a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -51,16 +51,6 @@ export function assert(value: unknown, msg?: string): asserts value { } } -export function isLikelyPageLoad(): boolean { - // without performance API, we can't tell if this is a page load - if (typeof performance === "undefined") { - return false; - } - - // if it's been < 5 seconds since the page was loaded, it's probably a page load - return performance.now() < 5000; -} - export function difference(a: any, b: any) { const result: Record = {}; diff --git a/src/xstateTree.tsx b/src/xstateTree.tsx index e1f710d..a6ad4ef 100644 --- a/src/xstateTree.tsx +++ b/src/xstateTree.tsx @@ -29,7 +29,7 @@ import { GetSlotNames, Slot } from "./slots"; import { GlobalEvents, AnyXstateTreeMachine, XstateTreeHistory } from "./types"; import { useConstant } from "./useConstant"; import { useService } from "./useService"; -import { assertIsDefined, isLikelyPageLoad, mergeMeta, toJSON } from "./utils"; +import { assertIsDefined, mergeMeta, toJSON } from "./utils"; export const emitter = new TinyEmitter(); @@ -449,7 +449,7 @@ export function buildRootComponent( } = routing; const initialMeta = { ...(routing.history.location.state?.meta ?? {}), - onloadEvent: isLikelyPageLoad(), + onloadEvent: true, } as SharedMeta; const queryString = getQueryString();