Bitpath

Lesson 1 · Unit 03

Render and commit

What triggers a render, why rendering must be pure, and when state is kept or reset.

13 exercisesabout 3 min

What you practise

  • What triggers a render, pure components, how React matches old and new trees, state that resets and state that sticks

Try a question from this lesson

Pick one

A click calls the setter for n in App. By default, which component functions does React call?

Page
├─ Nav
└─ App          state: n
   ├─ Header
   └─ List      n={n}
      └─ Row

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Trigger, render, commit

A screen update has three steps. Trigger: the first render, or a setter was called. Render: React calls your components to work out what the screen should look like. Commit: React compares that with the previous output and changes only the DOM nodes that differ. Then the browser paints. "Rendering" is calling functions, not drawing.

Concept

Pure components

React assumes every component is a pure function: the same props and state in, the same JSX out, and no changes to anything that existed before the call. Creating and changing your own local variables is fine. In return React may call components in any order, more than once, or skip calls. Changes to the outside world belong in event handlers.

10 more exercises in the app

  • 1× order the lines
  • 5× multiple choice
  • 1× true or false
  • 1× fill the blanks
  • 1× match the pairs
  • 1× type the answer

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy