Skip to content

Commit

Permalink
fix router hook recursively wrapping routes when patched multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
AAGaming00 committed Jul 4, 2023
1 parent 365866c commit dea0886
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/src/router-hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ declare global {
}
}

const isPatched = Symbol('is patched');

class RouterHook extends Logger {
private router: any;
private memoizedRouter: any;
Expand Down Expand Up @@ -90,9 +92,10 @@ class RouterHook extends Logger {
...routeList[index].props,
children: {
...cloneElement(routeList[index].props.children),
type: (props) => createElement(oType, props),
type: routeList[index].props.children[isPatched] ? oType : (props) => createElement(oType, props),
},
}).children;
routeList[index].props.children[isPatched] = true;
});
}
});
Expand Down

0 comments on commit dea0886

Please sign in to comment.