During Pre-rendering (SSR or SSG) you tried to access a router method
back, which is not supported.
In a function Component you can move the code into the
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.