React before Javascript: why you should never do that
--
For people who are learning React without the knowledge of Javascript, it feels like magic. Besides, React is easier to learn and there are so many resources these days. Can you get away with learning React without knowing much about Javascript? For beginners, yes, you can. Then why do people not recommend this: let’s find out.
But first, let’s know what Javascript and React are:
Javascript: Lets us add interactivity to the web apps
It is a high-level, interpreted programming language primarily used for creating interactive web pages and applications by adding dynamic behaviour and functionality to them. In simple terms, it makes websites a lot more functional and fun.
React: Lets us make it easy to create User Interface
It is a javascript-based library, mainly used to create User Interfaces. It uses Virtual DOM as opposed to Javascript. Facebook developed React to build its complex UIs efficiently. It was later open-sourced in 2013, which allowed React to grow exponentially and become what it is today.
After learning that Javascript comes under the hood of React, some of you might think, “It is an absolute no-brainer to learn Javascript before React,” and that’s almost true. But, with a little Javascript under your belt, you can start learning React, and there will be no problem until you start creating your apps or increasing the complexity by a little.
The main problem
“What is wrong with learning React first? I can watch a tutorial and understand what’s happening and why it is happening” — This is a valid question. And the answer to this is pretty interesting.
So, you may be able to understand what’s happening and how to make that happen again by watching a tutorial, but what you are missing out on is how it is happening in detail.
For example, you may or may not have heard of a map method before. Most of the beginner tutorials show you a list rendering in React using a map. The instructor also tells you when to use the map and when you can’t. But, it’ll be a passing cloud to you. I have many-a-times used array methods in the wrong way. You will not have much idea of the structure of objects or how to modify those objects. And you might directly jump into React, and when you try on your own, you’ll waste much more time on why it is not working this time than the time you could’ve invested in learning javascript properly.
Maybe your case requires you to write a loop for it (to make it functional or readable). That is just a basic example. There can be many issues if you don’t know the nuances in const, let, var, or anything about promises. So, it will be like you, walking into someone else’s home in the dark. Instead, if you learn Javascript and start React, you will not only be much more confident, but you will also understand better.
So, how much Javascript do you need to start learning React
That is very subjective and highly dependent on your patience. Many developers, myself included, keep learning forgotten Javascript concepts or previously ignored Javascript concepts on the go when we have to. But, it has always been recommended to learn the art of war before the battle and not from the opponents on the battleground. However, the easiest technique to learn the much-needed Javascript (only to learn React) faster is to code a few basic apps in Javascript by following tutorials or whatever you feel appropriate, then try to code one or two on your own.
Trust me when I say this, the more you think you’ve learned just by watching or reading something, the more you will be making a clown of yourself. I can give you a list of topics that you have to implement at least once to get a hold of JS :
- Javascript functions (including arrow, anonymous)
- Objects (syntax, how to use them)
- Arrays (main methods, how to use them)
- Ternary operators (very useful)
- Short conditionals (&&, || — again very very useful)
- ES modules export/import syntax
- Template literals (Strings)
Conclusion
Thanks for reading. I hope you liked my short post. I believe you now know what to learn first and how much to learn. Hoping that the world will see better React developers after reading this. Peace✌️
If you like my post, show me some love by recommending my post. Follow me on Twitter @Teja_1511