Skip to content

Commit

Permalink
feat: log createMemoryHistory items
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgrzybowski committed Jul 28, 2023
1 parent 255ed94 commit 90c8f45
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/native/src/createMemoryHistory.tsx
Expand Up @@ -14,6 +14,26 @@ export function createMemoryHistory() {
let index = 0;
let items: HistoryRecord[] = [];

// @ts-ignore no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const log = () => {
console.log(
JSON.stringify(
{
index,
indexGetter: history.index,
items: items.map((item, i) => ({
selected: history.index === i ? '<<<<<<<' : undefined,
path: item.path,
id: item.id,
state: item.state?.key || null,
})),
},
null,
4
)
);
};
// Pending callbacks for `history.go(n)`
// We might modify the callback stored if it was interrupted, so we have a ref to identify it
const pending: { ref: unknown; cb: (interrupted?: boolean) => void }[] = [];
Expand Down Expand Up @@ -215,6 +235,7 @@ export function createMemoryHistory() {
}

listener();
// log();
};

window.addEventListener('popstate', onPopState);
Expand Down

0 comments on commit 90c8f45

Please sign in to comment.