Performance in React
Most people are aware of the fact that React makes rendering things in the front-end super fast, but did you know that’s not always the case? If we take a look at the algorithms that work behind the scenes, we would come across some type of diff mechanism
, which is an algorithm to detect the differences between two separate contexts and give you back the only changed variable.
The Backbone
There are a couple of reasons for why React is blazing fast in rendering, one of them being mainly because it doesn’t refresh the entire page when an update is detected. It only refreshes what’s called the virtual DOM
, which is a copy of the actual DOM. This is then plugged into the diff algorithim
to detect what changed and what didn’t, and it only updates what was changed.
However, if we look specifically at how React works, then we know that every part of the virtual DOM
is composed of components
...