Skip to content

Commit 9f38df3

Browse files
committed
fix: PageCollector -> TypeError: Cannot set properties of undefined
1 parent c7733a8 commit 9f38df3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/PageCollector.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ export class PageCollector<T> {
9191
this.storage.set(page, storedLists);
9292

9393
const listeners = this.#listenersInitializer(value => {
94-
const withId = value as WithSymbolId<T>;
94+
let withId: WithSymbolId<T>;
95+
if (value === undefined || value === null) {
96+
withId = {} as WithSymbolId<T>;
97+
} else {
98+
withId = value as WithSymbolId<T>;
99+
}
95100
withId[stableIdSymbol] = idGenerator();
96101

97102
const navigations = this.storage.get(page) ?? [[]];

0 commit comments

Comments
 (0)