4 ms·
> The minimal reusable unit in React framework is React.Component Wrong. And if you think the correct answer is "function" then you are wrong as well. The answ
by wereHamster 10y ago
> The minimal reusable unit in React framework is React.Component
Wrong. And if you think the correct answer is "function" then you are wrong as well. The answer is: an Element. A pure, immutable value representing a React element. Example: const myReusableDiv = <div />;
> Developers have to manually replace class and for attributes with className and htmlFor.
So? It's just syntax. You can teach that, along value interpolation and everything that a designer might need to be able to make changes to templates, in less than five minutes to someone who only knows HTML.
> [talking about propTypes]. Yet this mechanism is full of holes.
So is JavaScript. Nothing to do with React. Scala is better, obviously. Any statically typed language is better at that. And there even are languages which are better at that than Scala.
If you are all like 'lol JS has no types, look at my fancy Scala code' then I'll smack you with my Haskell ADTs. And then somebody from the Agda or Idris camp joins and gives you a taste of dependent types.
> [how async programming is bad]
Nothing to do with React. React is just for rendering the UI. How you manage the data is entirely up to you.
- sarreph 10y ago> If you are all like 'lol JS has no types, look at my fancy Scala code' then I'll smack you with my Haskell ADTs. Gave me a good chuckle... But on a serious note, at least the author is providing a programmatic solution to the problem, albeit being framed rather one-sidedly.
- rickhanlonii 10y agoTo be fair <div /> is a function when converted from jsx to js
- wereHamster 10y ago<div /> is a constant. It's syntactic sugar for React.createElement("div"), which is at runtime represented as an object {type:'div', ...} and a few other fields. typeof <div /> === "object"
- rickhanlonii 10y agoI misspoke, yes it's a function call to React.createElement