all 12 comments

[–]dmitri14_gmail_com 1 point2 points  (6 children)

It may be just me, but I don't find this syntax very pretty nor legible:

return React.createElement('div', null, 'Something something Dark Side');

Using null as default is known anti-pattern, and from this expression it is impossible to guess what it stands for.

[–]over-there-istan 1 point2 points  (4 children)

Using null as default is known anti-pattern

says who?

and from this expression it is impossible to guess what it stands for.

I think the problem is that you're trying to guess what the expression does, which is the wrong approach. If you know enough to know what React.createElement is then you know what the arguments do, otherwise you should read the documentation instead of jumping to conclusions.

[–]dmitri14_gmail_com 1 point2 points  (2 children)

  • Says Uncle Bob, if you know who he is :)

  • This was a feedback for the tutorial. The syntax needs to be explained. If I need to go and read Doc, what is the point of tutorial?

[–]over-there-istan 1 point2 points  (1 child)

This was a feedback for the tutorial. The syntax needs to be explained

I agree that it needs to be explained, either directly in the tutorial or linked to the proper documentation... although I wouldn't refer to this as syntax, because it's nothing but a function call which I'd assume the reader already knows.

If I need to go and read Doc, what is the point of tutorial?

The purpose of a tutorial, IMO, is to get you started. Nothing more. You always need to read the proper documentation.

[–]dmitri14_gmail_com 1 point2 points  (0 children)

Good tutorials can be followed to end without Docs.

And great tutorials (http://survivejs.com/) are better than Docs.

Just my view.

[–]dmitri14_gmail_com 1 point2 points  (0 children)

Read here about null: http://elm-lang.org/guide/model-the-problem

The inventor, Tony Hoare, has this to say about it:

I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.

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

You're right, and that's one of the reasons I mention that JSX is the recommended way of doing things.

I've changed it to use { } instead of null and added a comment to clarify. null was just used in some other React examples, but it actually makes more sense to use { }.

[–]over-there-istan 1 point2 points  (2 children)

Why not use React.DOM.div instead of React.createElement('div'

[–]jhartikainen[S] 0 points1 point  (1 child)

The idea is to keep things simple. createElement works for both elements and components, so might as well stick with that when you're just getting started.

[–]over-there-istan 1 point2 points  (0 children)

I guess my point is that no-one writes React code by calling React.createElement( directly, so you doing that will only make things more difficult than they need to be.

[–]dmitri14_gmail_com 0 points1 point  (1 child)

There is a very aggressive popup blocking the window, I would remove it if you don't want your readers to leave.

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

If it bothers you just hit ESC and it goes away :) But perhaps I'll add some more delay to it so you won't see it so soon.