I've faced with hard to investigate bug with the browser's backward button on https://gart.gallery.
If you go to https://gart.gallery/artworks/
then to any artwork, for example, https://gart.gallery/artworks/my-place/ then click browser's backward –– the URL will be replaced by /artworks but the new page wouldn't be rendered.
My attempts to debug:
const Artwork = () => <p>Artwork page</p> the behavior stays the same pages/arworks/index.tsx
pages/arworks/[slug]/index.tsx
// everything is usual
/events/art-dubai/ and /events navigate through the browser back/forward correctly/events/[slug] which works correctly and /arworks/[slug], /artworks pages. Moreover, I tried to replace them with the simplest possible component with just a <p> or Link – behavior stays the same.arworks/[slug] => artworks, galleries/[slug] => galleries and artists/[slug] => artists but not for /events/[slug] => /events. Weird, I don't see what is in common or what is the difference_app.tsx on the events like: function handleStart(...props) {
console.log('start ', JSON.stringify(props));
start('ROUTER', 0);
}
function handleStop(...props) {
console.log('complete ', JSON.stringify(props));
finish('ROUTER', 500);
}
router.events.on('routeChangeStart', handleStart);
router.events.on('routeChangeComplete', handleStop);
I can provide any needed configs or files if it helps.
I do not hope to get a final solution, but I would be very grateful if someone could direct me on the way how to think/debug this.
UPDATE:
If i change NextLink on simple ... – it navigates to the artwork and than browsers backward works properly! So the issue has been localized: it is a problem with using NextLink. But still not clear why pages navigated through NextLink don't trigger the router to re-render component due to URL has been changed. I use Next link due to the doc:
<NextLink
passHref
href="/artworks/[slug]"
as={`/artworks/${product.slug}`}
/>
<a>...</a>
</NextLink>
Removing passHref or using just a href property – does no impact on bug.