I've done a lot of Web UI work in the past, but have yet to work with React. I'm familiar with the basics, but one question I haven't yet answered for myself is the Why of React.
So, in a nutshell, what would you say is the main problem that React is trying to solve?
I know that could get fairly philosophical, but I'm really looking for something just a level or two deeper than "It's better than X!"
Same problem that functions are trying to solve in regular programming languages, but applied to UI. Does this help? (Let me know if it’s too brief and I can expand. I was going for “a-ha” but maybe this just confused you more.)
Actually, if I understand what you're getting at, that helps a lot. I can definitely see the value in making the mental model of assembling a large, dynamic UI be similar to that of assembling a "normal" (for lack of a better word) program.
Yep, that’s about it.
The interesting difference from “normal functions” is that the “React functions” (we call them “components”) can be stateful. For example a Checkbox component doesn’t just “return” something unlike a normal function, but can be toggled on and off. We call this “state”.
The state in "React functions" (components) resembles C++'s local variables, defined inside functions using the static keyword. Such variables keep their value between function calls. If something similar existed in JS, you would be closer to being able to use functions to implement components exclusively, and avoid downsides of using classes that give you a hard time working on async rendering and compilation.
Also unfamiliar with React and have read some stuff about it and been largely unsure and this summary is seriously golden in my book and legit seals it on me checking it out more--because that's an explanation that makes total sense.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.