Skip to content

romellogoodman/react-children-render

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-children-render

A component for rendering children.

npm

Usage

import React from 'react';
import Children from 'react-children-render';

const Component = () => {
  return (
    <Children>
      <p>Foo</p>
      <p>Bar</p>
    </Children>
  );
};
<!-- HTML Output -->
<p>Foo</p>
<p>Bar</p>

Why?

Before React v16, returning adjacent JSX elements had to be wrapped in an enclosing tag.

import React from 'react';

const Component = () => {
  return (
    <div>
      <p>Foo</p>
      <p>Bar</p>
    </div>
  );
};

After React v16, a single component can return multiple components without an enclosing tag.

import React from 'react';

const Component = () => {
  return [
    <p key='1'>Foo</p>
    <p key='2'>Bar</p>
  ];
};

With react-children-render you can eliminate the need for unique keys.

About

A component for rendering children.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published