Skip to content

Instantly share code, notes, and snippets.

@barhoring
Created December 24, 2023 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barhoring/a0bf329e1f347663dfcad760ec8fb483 to your computer and use it in GitHub Desktop.
Save barhoring/a0bf329e1f347663dfcad760ec8fb483 to your computer and use it in GitHub Desktop.
Proxy on push state
const originalPushState = window.history.pushState;
window.history.pushState = function () {
// Your custom logic here before calling the original pushState
// Call the original pushState method
// @ts-ignore
return originalPushState.apply(window.history, arguments);
};
const Root = () => {
return (
<StrictMode>
<App />
</StrictMode>
);
};
const container = document.getElementById('root');
if (container) {
const root = createRoot(container);
root.render(<Root />);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment