Skip to content

Commit

Permalink
fix(react-binding): add then and else to static render of If
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed Jul 2, 2024
1 parent 68a4470 commit 0ccc696
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 0ccc696

Please sign in to comment.