Hacker News new | ask | show | jobs
by xdanger 2376 days ago
I'm not really sure how can you say that the React code is simpler or cleaner? Where do props come from? Where's the span for x? <li>'s are generated by magic?

I just don't like mixing html and js like that, maybe that's why it also seems messy to me.

The vue example also isn't the greatest, some cruft could be removed using default slot and shorter syntax.

1 comments

Both Vue and React have props. The above code is a snippet; I used the same format as the Vue documentation (which I agree is a little confusing).

> Where's the span for x?

I assumed Vue was only using the span for v-if, in React we don't need that extra node.

> <li>'s are generated by magic?

Whoops -- an omission on my part. They should be wrapping the inside of the mapping function.

> I just don't like mixing html and js like that, maybe that's why it also seems messy to me.

But this is where the magic is. It's exactly why React didn't need to invent a concept for "slots". I admit it's vaguely unfamiliar at first but if it increases both the power and simplicity of your template it's a no-brainer.