Skip to content
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

expanded on No Router Instance #21248

Merged
merged 6 commits into from Jan 26, 2021
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions errors/no-router-instance.md
Expand Up @@ -2,8 +2,12 @@

#### Why This Error Occurred

During SSR you might have tried to access a router method `push`, `replace`, `back`, which is not supported.
During Pre-rendering (SSR or SSG) you tried to access a router method `push`, `replace`, `back`, which is not supported.

#### Possible Ways to Fix It

Move any calls to router methods to `componentDidMount` or add a check such as `typeof window !== 'undefined'` before calling the methods
In a function Component you can move the code into the `useEffect` hook.

In a class Component, move any calls to router methods to the `componentDidMount` lifecycle method.

This way the calls to the router methods are only executed in the browser.