Skip to main content
CodeOath

Front-end and full stack · Chapter 6

React: components, state and effects

About this chapter

React turns data into a screen by calling functions, and much of the confusion comes from forgetting that. This chapter explains how props and state become what a user sees, why state behaves like a snapshot within one render, how events and forms feed state, how context, custom hooks and reducers share it, what effects are for, and when an extra render is worth fixing.

Who it is for: Developers who know JavaScript and basic front-end work and want a working mental model of how React renders, ahead of interview questions on hooks and re-renders.

You will be able to

  • Describe how props and state produce a screen, and why a component must not change its props.
  • Explain why state is a snapshot and how that changes what an event handler sees.
  • Choose between local state, context, a custom hook and a reducer for a piece of shared state.
  • Say what an effect is for, and what work belongs in rendering instead.
  • Decide whether an extra render is a problem worth fixing.

The key idea: A component works out what the page should look like from the data it is given. When something on screen is wrong, the useful question is which data it received on that render, not what React did.

In this chapter

  1. Paperlark's page as functions
  2. JSX and the rendering model
  3. Components, props and lists
  4. State, and why it is a snapshot
  5. Events and forms
  6. Composition, context, custom hooks and reducers
  7. Effects: synchronising with the world outside React
  8. Refs and avoiding extra renders
  9. Mistakes that recur

Locked: needs a plan

You can read chapter 1 free. Chapter 6 is the next one.

What you can do now, free: re-read chapter 1 and try its problems.

What a plan gives you: all chapters of the track you pick and their checks. Professional, one role is ₹329 a month or ₹2,299 a year. It renews until you cancel, and you can cancel any time. Paid plans open at launch.

Why is this locked?

Chapter 1 of every track is free, so you can see how the track reads. The rest of a track and its checks come with a plan, or open as you pass each chapter's check.

The price is for one period, a month or a year. A plan renews until you cancel.

Back to the track