DEV Community

Discussion on: Explain React.js Like I'm Five

Collapse
 
isas1 profile image
Mr.I • Edited

I’m drawing a finger painting and really want a yellow background but I only have three colour to use: red, green or blue.

With JavaScript, I add red paint to the canvas first, which makes the colour change. It looks different now; the state has changed. Next, I add some green paint and the colour changes to yellow (along with the canvas state).

With React.js I can mix the colours beforehand using a pot, which React calls a component, just before the canvas (and state) is updated.

Both ways work just fine but it’s bit annoying having to add the colours individually and keep track of the changing colours on the canvas. It’s much easier to mix the colours beforehand and add them straight to the canvas.

Collapse
 
letuche profile image
Letícia Monteiro

Now that is a "like I'm five" explanation! That's great, thank you. :)