Pendora takes a person's official pension and insurance snapshot and turns the raw industry data feed into a plain dashboard of what they own and what they are covered for. It also has a phone-friendly wizard for signing the consent form that lets the data be pulled. This note covers a failure in the detail view. A change made as an optimisation stopped the page from rendering.

Why does a hook placed after an early return crash a React component?

React identifies hooks by the order in which they are called during a render, not by name. Every render of a component must call the same hooks in the same sequence. An early return exits the component before the rest of its body runs, so everything below it becomes conditional. A typical example is a guard that returns a placeholder when some input is absent. That example is generic and does not describe the guards in this case.

If a hook sits below such a guard, renders that take the early return call fewer hooks than renders that pass it. When the same mounted component switches from one path to the other, the number of hooks changes between renders. React treats that as an error rather than something to reconcile. This is why the Rules of Hooks require hooks to be called only at the top level of a component, before any conditional return.

What happened in Pendora's detail view?

The round-4 work added memoisation to the detail view component. The memoisation sat below the component's existing early-return guards. The view crashed with React's changing-hook-count error. The record does not say which conditions the guards check or which sequence of renders triggered the crash. It establishes only the placement and the resulting error.

Why was the memoisation removed rather than moved above the guards?

The usual repair for this class of bug is to move the hooks above every early return. That keeps the memoisation, but the hooks then run on every render, including renders where the component is about to return early. Their inputs therefore have to tolerate those cases.

Pendora's fix took a different route. It dropped the memoisation entirely and replaced it with plain inline computation. The stated grounds were that the arrays involved are small enough that memoising them was never worth a hook. Inline computation adds no hook, so the ordering constraint no longer applies to that code. No guard placement can reintroduce the error through it.

When is memoisation actually worth a hook?

In general, a memo hook keeps a cached value and compares its dependencies on every render. It is also subject to the same call-order rules as any other hook, and this failure shows that cost. Common reasons a memo hook earns its place:

When none of these hold, inline computation is simpler to read and has no hook-ordering constraints.

What should teams check before adding memoisation to an existing component?

A memo hook changes the structure of a component as well as its performance profile. When adding one, check where it sits relative to every return path. Also check whether the data justifies a hook at all.