quick fix for routes refreshing constantly

This commit is contained in:
AAGaming
2022-07-24 11:51:42 -04:00
parent 2004bdebbf
commit 52dded85ed

View File

@@ -41,11 +41,16 @@ class RouterHook extends Logger {
const DeckyWrapper = ({ children }: { children: ReactElement }) => {
const { routes } = useDeckyRouterState();
const routerIndex = children.props.children[0].props.children.length;
let routerIndex = children.props.children[0].props.children.length;
if (
!children.props.children[0].props.children[routerIndex]?.length ||
children.props.children[0].props.children[routerIndex].length !== routes.size
!children.props.children[0].props.children[routerIndex - 1]?.length ||
children.props.children[0].props.children[routerIndex - 1]?.length !== routes.size
) {
if (
children.props.children[0].props.children[routerIndex - 1]?.length &&
children.props.children[0].props.children[routerIndex - 1].length !== routes.size
)
routerIndex--;
const newRouterArray: ReactElement[] = [];
routes.forEach(({ component, props }, path) => {
newRouterArray.push(