You should learn React even if you will never use it

I recently published a video course on React Fundamentals and while producing it I had the chance to think about the general ideas that React proposes, quoting Seneca homines dum docent discunt (while people teach, they learn).

My conclusion has been that learning React is useful even if you won’t ever write a single line of React code, because it’s a new mindset and makes you think about code in a whole different way.

Reactive

React is a reactive framework: you define the interface as a function rendering the data. You don’t need to handle the data changes, because React will run the function again and update the visible interface.

This approach simplifies greatly the code, because you can think about interface as a pure function. If you say let a = b + c , the assignment will be updated every time b or c change, so it's more of a definition than an assignment.

For example typing in a textbox will change the data that defines your view, so React will render your app again, the only thing you need to do is save the new value every time a user types.

If you are concerned about performance, don’t be, React handles this updates in a very smart way, not simply redrawing the whole interface every time.

Purity

React promotes pure functions and pure components: you shouldn’t rely on anything other than the props passed to the render function to generate the HTML view (except for the component's state, but you can think of it as an additional prop).

This makes the code a lot easier to debug, because you know exactly what data the function is handling, on the other hand with classic imperative programming you may access a global variable that could be modified from any line of code.

Data flows only down

In React parent elements wrap children, just like it happens in html: <div> <button/><button/> </div> . Data can only be passed from a parent element to a child.

You may think this pattern is too strict, but in fact you can handle any situation with ease and it avoids spaghetti code and promotes a single source of truth approach.

Wrapping up

React will teach how to think about your code in a more modular, pure and streamlined way. This will surely prove useful no matter what kind of coding you will be doing.

Ready to get learning? Check out my video course React Fundamentals, for you it's free!