Skip to content

05-prj-data-fetching useRouter Issue #48

@o-faro

Description

@o-faro

Hello, nice course, but there seems to be an issue with useRouter on pages/events/[...slug].js

Sometimes router.query.slug is an empty object and not only in pre-rendering phase. Especially wenn hitting enter instead of reloading the page.

To make sure not having any errors in my code I copied source code from your repo and changed the firebase url to my project.
I still get this error
image

I already did some research on this topic and tried to avoid this error by using 'router' Object in a useEffect without success. Using
useRouter().isReady as dependency did not work also. All in all quite unpredictable behaviour.

Also changed from "swr": "^2.2.1" to "swr": "^2.0.0" without success.
And also installed prj-05-data-fetching from this repository. Hitting enter a few times also leads to the described error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions