TroyAlford / react-jsx-parser

A React component which can parse JSX and output rendered React Components.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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?