Reading the React documentation or blog posts about React, you have undoubtedly come across the term declarative. One of the reasons why React is so powerful is because it enforces a declarative programming paradigm.
Consequently, to master React, it is essential to understand what declarative programming means and what the main differences between imperative and declarative programming are. The easiest way to approach the problem is to think about imperative programming as a way of describing how things work, and declarative programming as a way of describing what you want to achieve.
A real-life parallel in the imperative world would be entering a bar for a beer, and giving the following instructions to the bartender:
- Take a glass from the shelf.
- Put the glass in front of the draft.
- Pull down the handle until the glass is full.
- Pass me the glass.
In...