DEV Community

Visakh Vijayan
Visakh Vijayan

Posted on

React so far

So this is what I have learnt so far. Correct me if I am wrong.

  1. React is a UI library developed by Facebook. Meaning it's the V in the MVC.
  2. It uses the concept of Virtual DOM which makes it extremely fast.
  3. Everything in React is a component. Components are nothing but a portion of the DOM.
  4. There are props and states. While a prop cannot be changed, a state can be changed at runtime.
  5. There are different lifecycle events of a component - 7 exactly, which gives more control to the programmer to manipulate the component rendering.
  6. React is best for SPAs which is achieved by Router, Switch, Link etc components.

I shall break down the points further soon.

In brief, it's good as it doesn't seem too difficult, but I have heard Redux is quite complicated. So fingers crossed.

Top comments (6)

Collapse
 
deciduously profile image
Ben Lovy

I'd also caution against thinking of a component as a portion of the DOM, but rather a compartmentalized bit of your application. There can be and often are components which do not render anything - it's not as tightly coupled to the DOM as it seems.

Check out Presentational and Container Components for some talk about the pattern.

Collapse
 
vjnvisakh profile image
Visakh Vijayan

Oh I didn't know that. But how can there be a component without a view?

Collapse
 
deciduously profile image
Ben Lovy

A component could be responsible for making AJAX requests, and dispensing the response to a number of child components that do render, for example. There is nothing to view for the parent, it's just making requests to the server, but each child will depend on the data it provides. That way you can separate your concerns - the components responsible for displaying the data don't need to know about AJAX at all, they just get the data they need as props.

Collapse
 
alancampora profile image
Alan Campora • Edited

Hey good post!
Just one thing related to your first point. I guess that a few years ago, React was just a view layer library. Nowadays, React team has integrated new features like the new context api, suspense and so on. There fore I would say it is not a "just" a View anymore, it gives you a framework to creating FE apps.

I have a couple of videos about React in my youtube channel they could be useful for you!

Collapse
 
vjnvisakh profile image
Visakh Vijayan

Thank you so much. Will definitely check them out.

Collapse
 
danielattiach profile image
Daniel Attiach

Can hooks now replace redux?