-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browser back button is not working #1
Comments
Reached out to Snipcart support. Created minimal repo with reproduction for them: https://github.com/talhaguy/next-snipcart-store |
Haven't heard anything yet from Snipcart. I have opened an issue in their NextJS sample repo: snipcart/next-snipcart-store#1 |
I noticed that the If the history state is the issue, this sample code seems to resolve it: // _app.js
import { useEffect } from 'react';
import { useRouter } from 'next/router'
function useResetHistory() {
const router = useRouter()
useEffect(() => {
document.addEventListener("snipcart.ready", () => {
Snipcart.events.on('snipcart.initialized', (snipcartState) => {
router.replace(router.pathname)
});
});
}, [])
}
function MyApp({ Component, pageProps }) {
useResetHistory()
return <Component {...pageProps} />
}
export default MyApp |
…ton not working for first page - closes issue #1
Replication Steps
Expected
Page should go back again.
Actual
Page visually remains on the same one. The URL does change though.
The text was updated successfully, but these errors were encountered: