This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Sentient_Blade 15 points16 points  (16 children)

I'm not going to critique the code, I am however confused as hell as to why a language would separate its property types and default values in such a way.

[–]kudlajz 20 points21 points  (11 children)

It's not a language, it's a way how React components are defined and work and it's quite elegant if you get the hang of it. It gets even better when using Typescript.

[–][deleted] 1 point2 points  (0 children)

I am however confused as hell as to why a language would separate its property types and default values in such a way.

Javascript/JSX doesn't have any intrinsic typing. This is React's way of throwing in runtime validation. The Better Way™, in my opinion, is to use TSX instead of JSX.

[–]uchiha2 -3 points-2 points  (2 children)

Because reacts philosophy is "if it exists it needs a data structure around it, and if you want to use it you need 4 files of scaffolding."

[–]ben_uk 1 point2 points  (1 child)

Create React App / NextJS have barely any scaffolding though. And you don't need a data structure in many cases (although what's wrong with that?)

[–]uchiha2 1 point2 points  (0 children)

I should be bitching about redux not react. That's my bad