Dev Helpers

Developer journal

React

Component design, derived state, rendering and browser interactions.

← All categories

React

Percentage meter

A percentage meter needs both a bounded visual fill and a meaningful textual value. Handle a zero denominator before dividing.

Vertical typesetting sample

Vertical typesetting changes the reading direction and available inline space. Treat the sample text as content so it remains selectable and accessible.

Square cover crop

A square image crop gives a card grid consistent geometry. The crop anchor determines whether the most important part of a photo survives.

Batch weight summary

Batch weight combines quantity and unit weight. Convert all measurements to the same unit before aggregating them.

Ordered milestone summary

An ordered milestone summary should preserve the sequence's meaning when names wrap. Use distinct labels for completed, current and upcoming work.

Billable increment rounding

Billing in increments requires a clear rounding policy. Derive the number of blocks before formatting a monetary amount.

Date input with ISO default

A date input expects a calendar date string. Be careful when converting the current instant because UTC and local dates can differ near midnight.

Deferred search indicator

A deferred search indicator distinguishes the current input from a slower result list. Keep previous results visible while showing that a newer value is pending.

Alphabetized directory

A directory benefits from a locale-aware sort and an unchanged input array. Sorting a prop in place can reorder data owned by a parent component.

Font family comparison

Font comparisons are easier to judge when size, line height and sample text remain consistent. Otherwise the specimen changes several variables at once.

Linked article card

A linked card benefits from one clear destination. Avoid nested interactive elements that make clicking and keyboard navigation ambiguous.

Range span readout

The span of a range differs from the count of discrete values inside it. Define whether endpoints are inclusive before choosing the label.

Beat interval readout

A beat interval is the reciprocal of tempo scaled to milliseconds. Derive the interval during render so it follows the current tempo prop.

Empty bin locator

A warehouse view can identify empty bins by filtering numeric quantities. Avoid treating a missing reading as proof of zero stock.

Polite status region

A polite live region announces updates when assistive technology has an opportunity. Mount the region before changing its contents so the update can be detected.

Rectangle diagonal

A rectangle's diagonal can be calculated from its two side lengths. Keeping this as a derived value avoids synchronizing a third piece of state.

Stock availability label

An availability label derives from inventory and any reservation policy. Keep the visible wording consistent with the action a visitor can actually take.

Role badge with explanation

A role badge needs an explanation that remains accessible outside its colour coding. Keep its display separate from authorization decisions.

Line-preserving caption

Captions may contain deliberate newlines from an editor. A whitespace rule can preserve them without injecting HTML into the component.

Required field legend

A legend can explain what a required marker means. Each required input still needs its own accessible required state.

Native reset form

A native reset restores a form's default values. A controlled React field derives its value from state and may need an explicit state reset.

Native disclosure panel

A native disclosure carries keyboard behaviour and expanded state without React state. A custom summary still needs a useful label.

Whitespace reveal view

A whitespace inspection view makes invisible characters recognizable while preserving the original input. Copying and displaying can legitimately use different representations.

Named field group

A fieldset and legend establish a name for a group of related inputs. This context matters when several controls share short labels.

Plain text download link

A text download needs an appropriate filename and MIME type. Use the same content source for the on-screen preview and exported file.

Natural numeric order

Natural numeric sorting handles labels such as item 2 and item 10 in a familiar order. Use a collator with an explicit locale where order matters.

Geo URI anchor

A geographic link passes coordinates to a compatible map application. Give the link readable place information for browsers that handle the scheme differently.

Quarter identifier

JavaScript months are zero-based, while quarter labels start at one. Derive the quarter from the calendar convention your users expect.

Imposed outer spread

An imposed outer spread pairs pages that meet after folding. Print order therefore differs from the reading order of the finished booklet.

Palette token exporter

A palette exporter translates design data into a portable text representation. Keep stable token names so a cosmetic rename does not break consuming styles.