Skip to content

Commit

Permalink
Merge pull request #738 from contember/fix/if-static
Browse files Browse the repository at this point in the history
add then and else to static render of If
  • Loading branch information
matej21 authored Jul 2, 2024
2 parents 68a4470 + 0ccc696 commit 26d5d96
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/react-binding/src/helperComponents/If.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ const IfCallback = Component<IfCallbackProps>(

return <>{evaluated ? (children ?? then) : elseIn}</>
},
({ children }) => {
return <>{children}</>
({ children, then, else: elseIn }) => {
return <>
{children}
{then}
{elseIn}
</>
},
'IfCallback',
)
Expand All @@ -65,14 +69,16 @@ const IfFilter = Component<IfFilterProps>(
)
return <>{evaluated ? (children ?? then) : elseIn}</>
},
({ children, condition }, env) => {
({ children, condition, then, else: elseIn }, env) => {
const desugaredFilter = QueryLanguage.desugarFilter(condition, env)
const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)
const additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>

return <>
{additionalFields}
{children}
{then}
{elseIn}
</>
},
'IfFilter',
Expand Down

0 comments on commit 26d5d96

Please sign in to comment.