Skip to content

Fragment usage #84

@chronoDave

Description

@chronoDave

I'm trying to render a list as shown in the example but it assumes rendering a single element.

const list = [
  { key: 'a', value: '1' },
  { key: 'b', value: '2' }
];

const Example = () => new forgo.Component({
  render() {
    return list.map(item => [
      <p>{item.key}</p>,
      <p>{item.value}</p>
    ])
  }
});

In React, you could wrap listed items like this into a fragment which you can attach a key to.

return list.map(item => [
  <Fragment key={item.key}>
    {[
      <p>{item.key}</p>,
      <p>{item.value}</p>
    ]}
  </Fragment>
])

How would you do this in forgo?

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or requestmedium-priorityMedium PriorityquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions