Accessibility Built Once: Shared Components and Tests That Query by Role
Why accessibility is cheapest in the UI's shared components, and how tests that find elements by role and name double as an accessibility check.
A loyalty-app component hides the "Redeem" button when a member has fewer than 500 points. It reads like a tiny display detail, and it passes review in seconds. Six months later the kiosk team asks what the threshold is, the web team has changed it to 400, and nobody can say which of them is right.
The book offers a question for sorting UI code from business code, and it fits on a sticky note. Imagine another front end, say a kiosk, joining the system next month: would its developers have to reimplement this rule? When the answer is yes, the rule is business logic. It belongs in a Tool, and the screen receives the outcome through the API.
Apply it to the Redeem button. A kiosk, a partner widget or a phone app would all need the 500-point rule, so the rule is not about presentation. The server should decide whether redemption is possible, and the component should do nothing smarter than reflect the answer, for instance by greying the button when the response says redemption is unavailable.
Now try some things that pass the test in the other direction. Which tab of the account page is open, whether the user has touched a field yet, the zoom level of a seat map: a second client would make its own choice about each, so they stay in the screen. The test separates "how this client shows things" from "what the system believes".
The test has a useful corollary for forms. A browser can reuse the same Schema-layer validator the server uses and give instant feedback before submitting. The book calls that a courtesy to the user, and it adds the reminder that the server checks everything a second time, since a browser can be tampered with. Treat client-side checks as help for honest users, never as protection.
The second idea is about state. Teams often fetch data on page load, drop it into a global store, and then spend months keeping that copy in step with reality. The book's position is that the server remains the authority on domain data, so whatever the UI holds is a cache, and caches deserve tools built for caching.
Picture a bike-share app that lists nearby stations with their free bikes. Copy-and-sync looks like this:
// two sources of truth, and a bug waiting for a rental to finish
useEffect(() => {
fetchStations().then(setStationsInStore);
}, []);
// one source, refetched whenever it is declared stale
const { data: stations } = useQuery({ queryKey: ["stations"], queryFn: fetchStations });
With the first version, a rental completing on another screen leaves the store showing a bike that is no longer there, and someone must remember to patch the copy. With a cache library, the same event is a single instruction: after the rental succeeds, mark the station data stale and let the library fetch it again.
None of that is specific to LVD, and the library names are interchangeable. The architectural point is narrower: it keeps a second, hand-maintained version of the truth out of the UI layer, which is the cheapest synchronisation bug to avoid.
Both tests push the same way. Rules go down, behind the API, where one implementation serves every client. Data stays owned by the server, and the screen holds a short-lived view of it. What remains in the UI is genuinely UI: layout, interaction, and what the user has typed but not yet sent.
That thin residue is the point. It is the code that changes most, so it should be small, easy to replace and free of decisions that other clients would have to repeat. For what it looks like when this goes wrong at scale, see UI layer violations.
Ask the second-client question of every rule in a component, and treat every piece of server data as borrowed. Those two habits keep the layer that changes most from becoming the layer that knows most. The structure that makes them natural is covered in feature isolation in the UI layer, and the boundary the data arrives across in the UI-API boundary.