rsnext/test/integration/with-router/pages/router-method-ssr.js
JJ Kasper e112df4319 Throw error when router methods are used in SSR (#6550)
* Update to use the correct router instance in withRouter so error is
thrown when router method is used during SSR

* Revert changes to with-router and add error to methods on
direct router instance

* Extend Router and override methods with error instead

* Update ServerRouter, add err.sh, and add test
2019-03-07 17:13:38 +01:00

8 lines
213 B
JavaScript

import { withRouter } from 'next/router'
function RouterMethodSSR ({ router }) {
if (typeof window === 'undefined') router.push('/a')
return <p>Navigating...</p>
}
export default withRouter(RouterMethodSSR)