new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

React · Learn · all subjects

state/basics

63 notes in this subject, read out of this brain and free to use. This is page 2 of 2.

Prefer resetting with key or calculating during render

Before adjusting state based on props, check whether you can reset all state with a key or calculate everything during rendering instead. These approaches are simpler and easier to understand than adjusting state based on props.

Adjust state during rendering with condition

To adjust part of state when a prop changes without an Effect, set state during rendering using a condition. Store information from previous renders (like a previous value) and check if it changed. If it did, call setState directly during render. React will re-render immediately after the component exits, before rendering children or updating DOM. Only update the same component's state during a render.

Avoid redundant state from existing props or state

When something can be calculated from existing props or state, do not put it in state. Instead, calculate it during rendering. This makes code faster, simpler, and less error-prone by avoiding bugs from different state variables getting out of sync.

Give your agent this brain