Skip to content

Conversation

@tomcru
Copy link
Owner

@tomcru tomcru commented Feb 26, 2024

The previous implementation of patching the History API methods (pushState and replaceState) was causing them to increasingly nest within patched versions of themselves.

To fix this, a new flag isHistoryPatched was introduced to prevent redundant patching. The stopProgressOnHistoryUpdate function now checks if the flag is already set before applying the patch. Additionally, the flag is set to true after the patching is done to ensure it is only applied once.

Reference: TheSGJ/nextjs-toploader#68

Furthermore, this increases support for router.push.

Reference: TheSGJ/nextjs-toploader#71

The previous implementation of patching the History API methods (pushState and replaceState) was causing them to increasingly nest within patched versions of themselves.

To fix this, a new flag `isHistoryPatched` was introduced to prevent redundant patching. The `stopProgressOnHistoryUpdate` function now checks if the flag is already set before applying the patch. Additionally, the flag is set to `true` after the patching is done to ensure it is only applied once.

Reference: TheSGJ/nextjs-toploader#68
@tomcru tomcru merged commit 564d2fc into main Feb 26, 2024
@tomcru tomcru deleted the Fix-history-pushstate-and-replacestate branch October 11, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants