-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #144: Nested layouts infinite recursive call. #145
fix #144: Nested layouts infinite recursive call. #145
Conversation
2563292
to
269d60c
Compare
Have fully tested this. It works as expected. I wrote most of my notes as I solved the bugs in the issue comments. Feel free to check there. |
Other solutions I attempted to fix this. This was actually the solution that made me arrive to the simpler solution in this PR. This is longer because it rewrites the the recursion (I thought it was the culprit).
function RecursiveWrapper(props: { wrappers: FlowComponent[], children: JSX.Element, index: number }) {
return (
<Switch fallback={props.children}>
<Match when={props.index < props.wrappers.length}>
{(() => {
// const CurrentComponent = props.wrappers.at(-(props.index + 1)) ?? Passthrough; // Access in reverse (has unexpected behaviors)
const CurrentComponent = props.wrappers[props.index] ?? Passthrough;
return (
<CurrentComponent>
<RecursiveWrapper wrappers={props.wrappers} index={props.index + 1}>
{props.children}
</RecursiveWrapper>
</CurrentComponent>
);
})()}
</Match>
</Switch>
)
}
function Wrapper(props: { children: JSX.Element }) {
const pageContext = usePageContext();
const [wrappers, setWrappers] = createStore<FlowComponent[]>([]);
createComputed(() => {
setWrappers(
reconcile([
// Inner wrapping
...(pageContext.config.Layout || []),
// Outer wrapping
...(pageContext.config.Wrapper || []),
]),
].toReversed()),
);
});
return (
<RecursiveWrapper wrappers={wrappers} index={0}>
{props.children}
</RecursiveWrapper>
)
} |
@magne4000 WDYT? |
This looks perfect, thanks! Note: I don't know if those are limitations of SolidJS or actual bugs, we should probably look into that. |
Thanks Joël! I agree, planning to make small repros of the issue those limitations with SolidJS to confirm as well. Also btw I think I forgot to |
Published as |
No worries, I fixed it |
@Blankeos I talked with Joël and, if that's something you'd be up for, we would like to add you as one of the maintainers of |
Hi @brillout! would love to. Feel free to contact me on Discord :) |
Fixes #144
TL;DR; These are the two issues fixed: