A place for my notes, views and ideas. All posts are ordered in order of their publication date. For my and your reference an approximate time to read is also provided.

@WiseQuote: What problem reactjs tries to solve

21 October 2017

Since I dived into React head first in summer 2017 I thought it my be nice to remind myself (and others?) what problem React actually tries to solve. I found this fitting "painting a fence" analogy on Quora:

Say you are paid to paint a fence every day. Each day, there is a minor change to the pattern. Maybe today the change is a square that takes up a small part of one panel. But you have no process to paint anything but the whole fence. So every day, you paint that whole fence and make the small minor change when you get to that spot.

With React.js, you would have a way to paint just that square instead of the whole fence. React.js acknowledges that painting is time consuming and figures out how to determine what changed between the existing fence paint job and the new paint job. Then it just does the minimal amount of work to get the new pattern in place.

In the React.js world, the fence is of course the Document Object Model (DOM) of the page. React.js can calculate how the DOM needs to change to get from the old to the new. So you can do the least amount of DOM changes to get the desired DOM (which might be no change at all -- and this is the biggest win because the naive approach would rerender what is already present).

Cymen Vig on Quota