3 ms·
> it demands immutability, which JS has no native support for. You don't need native support, just don't mutate state when calling setState, which is a pretty
by root_axis 9y ago
> it demands immutability, which JS has no native support for.
You don't need native support, just don't mutate state when calling setState, which is a pretty simple rule to follow.
> it wants you to use FP,
This isn't really true. React components are often written as ES6 classes and stateless functional components are only functional insomuch as they are literally just a function. I can't think of any advanced FP concepts that are necessary for idiomatic React.
> JSX is a DSL
Technically true, but in practice it is just ES6 and the HTML side of JSX so closely resembles actual HTML that the DSL criticism loses most of its meaning.
> I've seen someone use && as a poor man's if statement
It may be a code smell, but it's certainly valid JavaScript and not a technique that could be correctly described as contributing to the idea that JSX is a "DSL". Also, you don't have to do that, just use an if statement or a ternary operation to compute your result outside of the JSX block and reference the resulting variable in the template part of the render function.