Skip to content

Show can't render multiple elements #13

@elhoucine

Description

@elhoucine

Hi @Amine-H I like the new release, the helpers look clean 👍

There is a little issue, Show supports only returning one element.

This will not work:

<Show if={true}>
  <ProjectItem />
  <p>Other element</p>
</Show>

React 16 supports this with Fragments, not sure if it will create compatibility issues with projects using older versions.

export default (props) => {
  const { if: visible, children } = props;
  if(visible){
    return <React.Fragment> {children} </React.Fragment>
  }

  return null;
}

Let me know if you have some solutions in mind.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions