We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 39457c2 commit 8279575Copy full SHA for 8279575
cosmos.proxies.js
@@ -0,0 +1,34 @@
1
+import React from 'react';
2
+import Router from 'next/router';
3
+
4
+class NextJSProxy extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
8
+ this.__realRouter = Router.router;
9
+ Router.router = createRouterMock();
10
+ }
11
12
+ componentWillUnmount() {
13
+ if (this.__realRouter) {
14
+ Router.router = this.__realRouter;
15
16
17
18
+ render() {
19
+ const { nextProxy, ...rest } = this.props;
20
+ const { value: NextProxy, next } = nextProxy;
21
22
+ return <NextProxy {...rest} nextProxy={next()} />;
23
24
+}
25
26
+function createRouterMock() {
27
+ return {
28
+ push: () => {},
29
+ prefetch: () => {},
30
+ replace: () => {},
31
+ };
32
33
34
+export default [NextJSProxy];
0 commit comments