DEV Community

Discussion on: The concepts that React tutorials usually skip over

Collapse
 
gruckion profile image
Stephen Rayner

How does this help me? Could you give 3 examples where this has helped you write better react?

Collapse
 
icncsx profile image
icncsx • Edited

Hi, Stephen! It's true that knowing how an internal combustion engine works doesn't necessarily make you a better driver. But it does certainly help you understand why you should get an oil change or not put regular fuel in a premium-fuel only car.

As for me personally, I like knowing these details about React because they help me with debugging. Knowing that JSX is just a JavaScript object at the end of the day helps me understand that diffing in React-speak is simply the process of comparing two JavaScript objects. Now objects can have many things in them including other objects. When you compare two objects which are reference types, it can be quite tricky for JavaScript to figure out if they are "deeply" equal. This is why you would use immutable data structures when setting state. Otherwise, even if the contents of those objects have changed, React which uses a shallow equality check, would not deem two objects to be unequal.

Collapse
 
merri profile image
Vesa Piittinen

It is always good to know why you're doing whatever you're doing instead of blindly following a pattern and being like "ok this is magical but it works".