Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
render-fragment
Advanced tools
A convenient way to return a JSX fragment without the wrapping `div` element and not worry about the version of React.
A convenient way to return a JSX fragment without the wrapping div
element and not worry about the version of React.
$ 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.
FAQs
A convenient way to return a JSX fragment without the wrapping `div` element and not worry about the version of React.
The npm package render-fragment receives a total of 3,476 weekly downloads. As such, render-fragment popularity was classified as popular.
We found that render-fragment demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.