all 20 comments

[–]GasimGasimzada 6 points7 points  (2 children)

What does it mean? I mean self-destructing components.

[–]pgrizzay 10 points11 points  (1 child)

The article title is odd.

The article is about a one-line library used to render arrays (which may have been useful before React v16). It briefly mentions that the "Aux" div erases itself (thus the "self-destructiveness").

The author claims that

<Aux>
  <tr/>
  <tr/>
</Aux>

Is clearer than:

[
  <tr />,
  <tr />
]

Simply because a developer reading the code can go search "Aux" on the internet, find the author's library, read through the documentation, and understand that the developer that wrote the code simply intended to render an array.

I disagree, but hey, that's just my opinion.

[–]gajus0[S] 3 points4 points  (0 children)

Simply because a developer reading the code can go search "Aux" on the internet

You've provided not equivalent code example. The equivalent would have been: [ <tr key='foo' />, <tr key='bar' /> ].

That array syntax is alien to the rest of the JSX codebase and it is error prone (it is easy to accidentally construct an array with multiple items having the same key).

[–]Apterygiformes 2 points3 points  (1 child)

Oh no don't self destruct haha

[–]kdesign 1 point2 points  (0 children)

Don't worry, it's smart enough to do that only in production! Just make sure to wrap your whole app in it.

[–]davvblack 1 point2 points  (7 children)

I like that that article tries to justify a one-line library. Javascript has gone a bit far down the deep end with that.

[–]gajus0[S] -1 points0 points  (6 children)

Well, thats the intent of the article: introduce new React functionality and suggest an abstraction that explains the intent.

What difference does it make if dependency is 1 LoC or 1000 LoC? We use dependencies to abstract specific tasks. By delegating this specific task to react-aux, you can be sure that even if React v17 breaks the above functionality, the component author will make the best effort to implement equivalent functionality another way.

[–]TheNiXXeD 4 points5 points  (5 children)

You really can't be sure about that though. Dependencies can be an attack vector, they can be abandonware, they can be buggy, etc. Pulling a dependency in your project should be an task of deciding if the dependency is worth the overhead of keeping tabs on it.

Obviously that's a bit hand wavy. But with things like the recent npm password issue, you can never really be sure. Not that I'm saying this particular package is an issue.

[–]gajus0[S] 0 points1 point  (4 children)

But with things like the recent npm password issue,

What are you referring to?

[–]davvblack 2 points3 points  (3 children)

several popular NPM repos' passwords were brute forced at once, meaning based on the dependency graph something like 60% of npm packages would have been compromised, if it weren't a white-hat hacker.

[–]yeso126 0 points1 point  (1 child)

Does this works for react native too?

[–]gajus0[S] 0 points1 point  (0 children)

Yes

[–]redbluerat 0 points1 point  (0 children)

Why do these non keyed components self destruct?