Skip to content

Commit 00d453d

Browse files
authored
expanded on No Router Instance (vercel#21248)
Added more detailed explanation of why there is no router instance, and other ways to fix the error
1 parent c110e45 commit 00d453d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

errors/no-router-instance.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
#### Why This Error Occurred
44

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

77
#### Possible Ways to Fix It
88

9-
Move any calls to router methods to `componentDidMount` or add a check such as `typeof window !== 'undefined'` before calling the methods
9+
In a function Component you can move the code into the `useEffect` hook.
10+
11+
In a class Component, move any calls to router methods to the `componentDidMount` lifecycle method.
12+
13+
This way the calls to the router methods are only executed in the browser.

0 commit comments

Comments
 (0)