https://github.com/donavon/render-array
https://github.com/donavon/render-array
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/donavon/render-array
- Owner: donavon
- License: mit
- Created: 2017-07-30T14:07:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-15T19:50:57.000Z (about 8 years ago)
- Last Synced: 2025-02-08T07:20:06.683Z (8 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# render-array
A convenient way to return an array of JSX wihout the wrapping `div `element when using React 16.
## Install
```bash
$ npm i --save render-array
```React 16 allows you to return an array, but you must use the following syntax:
```js
const App = () => [
A,
B
];
```See the awkward comma after the first `div`? [I sent a tweet](https://twitter.com/donavon/status/891632825543348224) to Dan Abramov about this and he replied:
> _We were might explore something like \<\>\
\\<\/\> in the future_Not exactly an optimal solution either, IMO. In the mean time, I wrote `RenderArray` so your can code like this:
```js
const App = () => (
A
B
);
```
It looks the same as components you are used to in React 15, but it returns the children _without_ a wrapping `div` element.See live example on [CodeSandbox](https://codesandbox.io/s/o2oQ9B3Q3).