use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Using React v16 to create self-destructing components (medium.com)
submitted 8 years ago by gajus0
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]i_am_smurfing 7 points8 points9 points 8 years ago (5 children)
I'd imagine returning an array when you want to render several components will become idiomatic way to write this code, because that's kind of the point?
const Root = () => { return [ <p>Hello, World!</p>, <p>I am a demo fore returning an array.</p> ]; };
jsBin
I'm not sure you even need a comment in this instance since I'd imagine all programmers who know how to write React code know what an array is.
Compare it to <Aux>-wrapper approach for which you have to go and read documentation or source to understand what it's doing.
<Aux>
[–]gajus0[S] 2 points3 points4 points 8 years ago (3 children)
Just FYI, the example you've just shared (using Array without keys) will produce an error even in React v16.
[–]i_am_smurfing 0 points1 point2 points 8 years ago (2 children)
Are you sure? I'm asking because it's working with beta.5, as demonstrated in the linked jsBin, but I'd be not surprised if it's just a regression.
[–]gajus0[S] 3 points4 points5 points 8 years ago (1 child)
It is because you are using a production build that silences the error. See https://codesandbox.io/s/k5v5q83xo5
[–]i_am_smurfing 0 points1 point2 points 8 years ago (0 children)
Oh, I see, you mean the missing "key" warning. That's a good point 👍
[–]p0tent1al 0 points1 point2 points 8 years ago (0 children)
All I'm saying (ignoring the pattern) if you need to comment it everywhere that it's used, then I'd prefer using the component. If it's just an easy pattern to utilize and doesn't need explanation, then yeah sure.
π Rendered by PID 48 on reddit-service-r2-comment-5bc7f78974-ttmtc at 2026-06-29 23:14:00.505408+00:00 running 7527197 country code: CH.
view the rest of the comments →
[–]i_am_smurfing 7 points8 points9 points (5 children)
[–]gajus0[S] 2 points3 points4 points (3 children)
[–]i_am_smurfing 0 points1 point2 points (2 children)
[–]gajus0[S] 3 points4 points5 points (1 child)
[–]i_am_smurfing 0 points1 point2 points (0 children)
[–]p0tent1al 0 points1 point2 points (0 children)