Skip to content

Commit

Permalink
Merge pull request #145 from Blankeos/fix/infinite-recursion-nested-l…
Browse files Browse the repository at this point in the history
…ayouts

fix #144: Nested layouts infinite recursive call.
  • Loading branch information
magne4000 authored Dec 19, 2024
2 parents 98da7f5 + 269d60c commit 985f346
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vike-solid/integration/getPageElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function Wrapper(props: { children: JSX.Element }) {
...(pageContext.config.Layout || []),
// Outer wrapping
...(pageContext.config.Wrapper || []),
]),
].reverse()),
);
});

const renderWrappers = (i: number = 0) => {
let item = wrappers.at(-(i + 1));
let item = wrappers[i]; // Assumes reversed, and must access with `[i]` instead of `.at(i)` otherwise, wrapper's states are not persisted.

if (!item) return props.children;

Expand All @@ -46,7 +46,7 @@ function Wrapper(props: { children: JSX.Element }) {
});
};

return <>{renderWrappers()}</>;
return <>{renderWrappers(0)}</>;
}

function Page() {
Expand Down

0 comments on commit 985f346

Please sign in to comment.