Skip to content

Commit

Permalink
Reintroduce renderPath to middlewares. Improve ComponentOrComposition…
Browse files Browse the repository at this point in the history
…Props type.
  • Loading branch information
NathanP-7West committed Apr 12, 2024
1 parent 6fdfc22 commit 2a0c711
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/json-react-layouts/src/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export type MiddlwareHandler<TProps, TMiddlewareProps extends {}, LoadDataServic

interface ComponentOrCompositionProps {
layoutType: string
[props: string]: any
renderPath: string
[props: string]: unknown
}

export type RendererMiddleware<Services extends {}, MiddlewareProps extends {}> = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export const ComponentRenderer: React.FC<ComponentRendererProps> = ({
return rendered
}

const { componentType, ...rest } = componentProps
const { componentType, componentRenderPath, ...rest } = componentProps

const middlewareRender =
componentMiddleware(
{ layoutType: componentType, ...rest },
{ layoutType: componentType, renderPath: componentRenderPath, ...rest },
middlewareProps,
componentServices,
render,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const CompositionRenderer: React.FunctionComponent<CompositionRendererPro
compositionMiddleware(
{
layoutType: composition.type,
renderPath: componentRenderPath,
...composition.props,
},
middlewareProps,
Expand Down

0 comments on commit 2a0c711

Please # to comment.