Skip to content

Commit

Permalink
YES2
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet committed Oct 22, 2024
1 parent 5375193 commit 64629fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions demo-app/resources/js/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ createInertiaApp({
const root = createRoot(el);

root.render(
<App {...props}>
{renderApp(props)}
</App>
renderApp(App, props)
);
},
progress: {
Expand Down
10 changes: 6 additions & 4 deletions react/src/ModalRoot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export const useModalStack = () => {

export const modalPropNames = ['closeButton', 'closeExplicitly', 'maxWidth', 'paddingClasses', 'panelClasses', 'position', 'slideover']

export const renderApp = (pageProps) => {
export const renderApp = (App, pageProps) => {
if (pageProps.initialPage) {
pageVersion = pageProps.initialPage.version
}
Expand All @@ -409,12 +409,12 @@ export const renderApp = (pageProps) => {
resolveComponent = pageProps.resolveComponent
}

return ({ Component, key, componentProps }) => {
const renderInertiaApp = ({ Component, key, componentProps }) => {
const modalRoot = createElement(ModalRoot)
const child = createElement(Component, { key, ...componentProps })

if (typeof Component.layout === 'function') {
return <ModalStackProvider><>{Component.layout(child)}{modalRoot}</></ModalStackProvider>
return <>{Component.layout(child)}{modalRoot}</>
}

if (Array.isArray(Component.layout)) {
Expand All @@ -424,8 +424,10 @@ export const renderApp = (pageProps) => {
.reduce((children, Layout) => createElement(Layout, { children, ...componentProps }))
}

return <ModalStackProvider><>{child}{modalRoot}</></ModalStackProvider>
return <>{child}{modalRoot}</>
}

return <ModalStackProvider>{createElement(App, { ...pageProps, children: renderInertiaApp })}</ModalStackProvider>
}

export const ModalRoot = ({ children }) => {
Expand Down

0 comments on commit 64629fe

Please sign in to comment.