JSX template with inline maping function
QuentinVrel opened this issue · comments
Hello, and thank you for this library which does exactly what I have been looking for !
I would have liked to include an in-line mapping function whithin the JSX and it seems not to be possible as said in the README. My use case is that I want to render a menu in an Ionic app based on a JSON list of items and a JSX template with a mapping function.
<IonMenu contentId="main" type="overlay">
<JsxParser
bindings={{
items: menu,
}}
components={{ IonList, IonMenuToggle, IonItem, IonLabel }}
jsx={jsxString}
/>
</IonMenu>
<IonList id="labels-list">
{items.map((item, index) => (
<IonMenuToggle key={index} autoHide={false}>
<IonItem routerLink={item.URL} routerDirection="none" lines="none" detail={false}>
<IonLabel>{item.title}</IonLabel>
</IonItem>
</IonMenuToggle>
))}
</IonList>
Is there any way to do such a thing using this library?
At the moment, you will need to define the mapping function as one of the
bindings, then you can use it inside the jsx.
…On Tue, Mar 9, 2021, 01:25 QuentinVrel ***@***.***> wrote:
Hello, and thank you for this library which does exactly what I have been
looking for !
I would have liked to include an in-line mapping function whithin the JSX
and it seems not to be possible as said in the README. My use case is that
I want to render a menu in an Ionic app based on a JSON list of items and a
JSX template with a mapping function.
<IonMenu contentId="main" type="overlay">
<JsxParser
bindings={{
items: menu,
}}
components={{ IonList, IonMenuToggle, IonItem, IonLabel }}
jsx={jsxString}
/>
</IonMenu>
<IonList id="labels-list">
{items.map((item, index) => (
<IonMenuToggle key={index} autoHide={false}>
<IonItem routerLink={item.URL} routerDirection="none" lines="none" detail={false}>
<IonLabel>{item.title}</IonLabel>
</IonItem>
</IonMenuToggle>
))}
</IonList>
Is there any way to do such a thing using this library?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#185>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC5R27BZJBUIRBFPN2TJSWTTCXSQ3ANCNFSM4Y3EZN5A>
.