Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

render-fragment

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

render-fragment

A convenient way to return a JSX fragment without the wrapping `div` element and not worry about the version of React.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.3K
decreased by-59.23%
Maintainers
1
Weekly downloads
 
Created
Source

render-fragment

A convenient way to return a JSX fragment without the wrapping div element and not worry about the version of React.

Install

$ npm i --save render-fragment

With the introduction of React 16.2, you can now return a fragment (i.e. multiple elements that are not under a single element). In previous versions, you were required to return either a single element (in version 15.x) or an array (in version 16.0 and 16.1).

import Fragment from 'render-fragment';

const App = () => (
  <Fragment>
    <div>A</div>
    <div>B</div>
  </Fragment>
);

If you are running React 15.x, it will render a wrapping <div>. For React 16.0 and 16.1, it will render an array. For React 16.2 and above, it will render a <React.Fragment>.

This way you can use the same markup regardless of the version of React that you are using. This is really useful for component designers that have React installed as a peerDependency.

See live example on CodeSandbox.

Keywords

FAQs

Package last updated on 30 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc