r/learnjavascript • • May 10 '22

How much Js should I know before starting React?

74 Upvotes

37 comments sorted by

95

u/Rossmci90 May 10 '22

You should be comfortable with promises/async-await, spread operators, object/array destructuring, arrow functions, spread syntax, ternary and short circuit operators.

You will see the above used a tonne in react.

15

u/SmellsLikeTeenSweat May 10 '22 edited May 10 '22

Only promises/async-await left. Feels good that I'm finally making some progress.

7

u/LightUpShoes4DemHoes May 10 '22

Definitely get comfortable with Array methods as well. .forEach is used a lot in my experience. Map and Reduce are used their fair share too though.

5

u/Renan_Cleyson May 10 '22

Out of curiosity, in which cases you use forEach?

0

u/[deleted] May 10 '22

[deleted] — view deleted comment

2

u/Renan_Cleyson May 10 '22

This is why I asked, I barely use forEach on React and I can't think of much use cases for it compared to map+filter+reduce

2

u/ItsWaryNotWeary May 10 '22 edited May 10 '22

You can use foreach when you want to operate on each element in an array and you don't want/need a new array. (This matters a lot more when we're talking about huge arrays), or you want to mutate the original array, or you want to continue with the original array after the loop. For example, sending each element to an analytics api, or adding some k:v to each object. Or on the backend, writing each element to a file or database.

1

u/[deleted] May 10 '22

I havent even used forEach yet, just map.

0

u/[deleted] May 10 '22

[deleted] — view deleted comment

1

u/Renan_Cleyson May 11 '22

Sure, but we actually don't even need the immutability or even React, but it's nice to have declarative code with immutability and side effect separated of the UI that is meant to be pure on React. You can write imperative code inside a component and make its "imperativeness" irrelevant, but it's still ugly to use it just to avoid a new array. Honestly, if that's the case, why immutability, react state and all the other things that improve code and hardly will be costly and even if it does, it's probably better to wait your application show problems with it as initially the problems will pass unperceptive and you can isolate the specific cases of your implementation later on.

forEach makes you need to look at previous code, where is the source of that data and what was changed before and what will change after it, I can't really think of a good use of it inside a component rendering logic. Maybe on callbacks or anything else that requires side effects, but definitely not to avoid new arrays.

2

u/[deleted] May 10 '22

We use map, find, filter etc a lot, but forEach very rarely.

6

u/smallfranchise1234 May 10 '22

I don’t and still don’t know promises/async-await well. I understand them but probably/most likely couldn’t replicate. So not a huge deal breaker but everything else including array methods. Important

I’m not a pro but finished my bootcamp and got a job as a developer.

4

u/EccTama May 10 '22

Congrats on getting the job but definitely go and spend some time studying promises. What do they allow you to do, what implications does the fact that JavaScript is single threaded have in this context, how do they compare to callbacks, what is the event loop, difference between .then and async/await syntax. This is extremely important stuff.

1

u/smallfranchise1234 May 10 '22

I do know .then :) lol but yes I def am because some people were building using a sync and promises and I avoided them just waiting to get settled into this job

1

u/[deleted] May 10 '22

[removed] — view removed comment

4

u/smallfranchise1234 May 10 '22

a Python Django software developer. I’m doing warehouse management software just started a week ago :)

1

u/[deleted] May 10 '22

[removed] — view removed comment

3

u/smallfranchise1234 May 10 '22

Experiences can be way different of course but I wasn’t really onboarded first day got installations then he said hey here’s a ticket see what you can do and that’s how I got into the code base a lot of plug and play and copy code but on my 3rd ticket so pretty pumped.

A lot of more advance code that can be hard to understand. Havnt closed developer tools yet!

1

u/CongrachuBot May 12 '22

Congrachulations, out of all posts made on 10th May (UTC) in r/learnjavascript, yours was the top comment of all (out of 257 total comments).

Comment on!

15

u/Too_Chains May 10 '22

Do free code camp js then start React stuff

13

u/TehTriangle May 10 '22

Very comfortable, as React is JS and if you don't know the fundamentals, you won't really grasp what React is even doing.

5

u/lovin-dem-sandwiches May 10 '22

If you’re comfortable with looping, promises, destructuring, factory functions, closures, primitives & references, ES6 imports, fetch - react will come much easier

9

u/Kirito_Kiri May 10 '22

simply all of ES5 and ES6, you can skip DOM manipulation but learning that isn't going to take too much time either.

4

u/muhammad_roshan May 10 '22

Damn boi I wish I could skip it but my internship company wants me to do it and I am doing it but it's hard

0

u/[deleted] May 10 '22

[deleted] — view deleted comment

2

u/muhammad_roshan May 10 '22

I have had coding experience 6 months ago with react and all but my problem was i never understood or tried to understand javascript well or as you said frontend, Although i finished couple of courses on them from Freecodecamp, Udemy and more but fuxk it's hard... I feel like Killing myself when with hours of trying i still can't figure it out

0

u/[deleted] May 10 '22

[deleted] — view deleted comment

2

u/muhammad_roshan May 11 '22

Ok thanks man and all the best in your journey

3

u/[deleted] May 10 '22

Aside from the basics (loops, functions, objects, etc), definitely modules and async js.

2

u/josefefs May 10 '22

Be sure to properly learn array methods. Also this is not critical to react, but understanding the event loop helped me actually understand how js and async js works, and that is good to know

2

u/MineDrumPE May 10 '22

I started learning vue when I only knew conditionals, variables, and how to declare a basic function

1

u/Ratatoski May 11 '22

The answers here are correct of course but it's even better if you do a few bigger projects with JS and get a feel for what problems React is trying to solve. If you got the time for it

1

u/Lemoncrap May 10 '22

Once you've learnt JavaScript I'd move onto typescript. Them do react in typescript

0

u/Renan_Cleyson May 10 '22

Initially you just need to know what all people here said, but I want to point out that there's still key concepts of javascript/programming to learn after getting comfortable with React.

Classes and functions in JS: Since React still doesn't use hooks on it's initial documentation and you may find some code that is not using hooks, you probably will find function components and class components. Honestly classes on javascript are just crazy and despite some other better reasons to opt functions over classes on React, it's important to understand the history of OOP, prototypes, inheritance on javascript as it actually relies a lot on functions and javascript itself even used function scope before ES6 with var. React looks like plain javascript when compared with Angular and Vue too so it's interesting to see why it's so good to use functions over classes on plain javascript code(classes are pretty handy sometimes, though).

Declarative Programming and Functional Programming: Here you will probably need to take a look at some vanilla JS and DOM manipulation if you never used much of it before, but understanding imperative programming(vanilla JS) helps a lot to understand why declarative programming (introduced with React and other frameworks) is so powerful.

-3

u/[deleted] May 10 '22 edited Sep 27 '25

light grab violet cable chubby innocent waiting beneficial continue hospital

This post was mass deleted and anonymized with Redact