Live data from Hacker News

How Does React Tell a Class from a Function?

overreacted.io

141–142 of 142 posts

Re: How Does React Tell a Class from a Function?

#141
post #55

Earlier quoted context omitted.

While I agree with your point, your example of React literally adds a DSL that requires a pre-compilation step. It's not required[0], I get that, but it's still a new language. [0]: It may not be required, but it was created for a reason....

JSX is not only not required, it's sugar that breaks referential transparency: https://medium.com/@david.chambers/jsx-violates-referential-... Personally I still use it, but I think it's fair to say that as much as JSX was created for a reason, it's made optional for a reason too.

[deleted]

Re: How Does React Tell a Class from a Function?

#142
post #55

Earlier quoted context omitted.

JSX is not only not required, it's sugar that breaks referential transparency: https://medium.com/@david.chambers/jsx-violates-referential-... Personally I still use it, but I think it's fair to say that as much as JSX was created for a reason, it's made optional for a reason too.

JSX doesn't violate referential transparency. A component either is referentially transparent, or it isn't; nothing about how it's invoked changes that. Put another way: React calls your components, not you. You pass the component function itself to React.createElement, not its result.

> You pass the component function itself to React.createElement, not its result.

JSX prevents you from being able to do this directly. For example, "hello" /> is illegal.

Post reply on HN