Closed lid0a closed 5 months ago
Update your links to other recipes, with shallow false, as follows:
<Link href={`/recipes/${recipe.idMeal}`} shallow={false}>
{recipe.strMeal}
</Link>
And then add this useEffect
, here src/pages/recipes/[id].tsx
:
useEffect(() => {
setRecipes([recipe]);
}, [recipe]);
This is to resync with the new head recipe sent from GSSP.
Update your links to other recipes, with shallow false, as follows:
<Link href={`/recipes/${recipe.idMeal}`} shallow={false}> {recipe.strMeal} </Link>
And then add this
useEffect
, heresrc/pages/recipes/[id].tsx
:useEffect(() => { setRecipes([recipe]); }, [recipe]);
This is to resync with the new head recipe sent from GSSP.
Thanks! Now it works. And useEffect
is enough as the shallow
prop is false
by default
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/prod-firefly-j4mlsw
To Reproduce
Run the application in either dev or prod mode
Open the sandbox window in a new tab
Click on any link in the list
Click on any link in the sidebar
Current vs. Expected behavior
I'm trying to implement infinite scrolling feed with url sync, i.e. while scrolling url should be
/recipes/<ACTIVE_ITEM_ID>
, where<ACTIVE_ITEM_ID>
- id of the item, which is in the center of the browser's viewport. I'm implementing this using intersection observer, window scroll event and location history. My infinte scrolling logic works as expected, but when I want to navigate to another page, UI isn't updated although url is updated. Screencast from 05-10-2024 05_49_23 PM.webmProvide environment information
Which area(s) are affected? (Select all that apply)
Navigation, Pages Router
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
By the way, the same code for app router works correctly https://codesandbox.io/p/devbox/recipes-app-router-vzf6mw