Unverified Commit 00d453d7 authored by Azeez Lukman's avatar Azeez Lukman Committed by GitHub

expanded on No Router Instance (#21248)

Added more detailed explanation of why there is no router instance, and other ways to fix the error
parent c110e45b
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
#### Why This Error Occurred #### 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 #### 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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment