Overview: React uses a declarative way to manipulate the UI. Instead of manipulating idividual pieces of the UI directly, you describe the different states that your component can be in, and switch between them in response to the user input. This is similar to how designers think about the UI.
You will learn
How declarative UI programming differs from imperratibe UI programming
How to enumerate the different visual states your component can be in
How to trigger the changes between the different visual states from code
How declarative UI compares to imperative
Thinking about UI declaratively
Step 1: Identify your component's different visual states
Step 2: Determine what triggers those state changes
Step 3: Represent the state in memory with useState
Step 4: Remove any non-essential state variable
Step 5: Connect the event handlers to set state
Recap
Declarative programming means describing the UI for each visual state rather than micromanaging the UI (imperative).
When developing a component:
Identify all its visual states
Determine the human and computer triggers for state changes.
Model the state with useState
Remove non-essential state to avoid bugs and paradoxes.