accepted

SmallMultiples passes shared-view hints through `renderCell`, not React context

`renderCell(datum, index, view)` receives a third `SmallMultiplesView` argument carrying `pitchOrientation`, `pitchCrop`, and `sharedScale`. Consumers opt-in per chart by forwarding `view` into children. Implicit React context was rejected — it breaks SSR, static export, and agent-readability.

SmallMultiples architectureapicore-contract

Context

Small multiples grids often need facet-level coordination: every pitch oriented the same way, every colour scale normalised to a shared domain. Two ways to wire it:

  • Implicit context — SmallMultiples provides a React context; child charts subscribe silently. Zero boilerplate but invisible in the render tree — consumers can’t tell which hints each chart honours without reading source.
  • Explicit forwardingrenderCell receives a view argument; consumers pass it into children they want to participate. Slightly more code; totally legible to humans and agents.

Context works in client-only React. It fails in SSR when the pitch primitive needs to serialise, and it can’t be consumed by non-React renderers at all.

Decision

renderCell signature is (datum, index, view: SmallMultiplesView) => ReactNode. The view bundle includes pitchOrientation?, pitchCrop?, sharedScale?. Consumers spread relevant fields into child charts: <ShotMap shots={d.shots} sharedScale={view.sharedScale} />. Charts document which fields they accept; SmallMultiples does not introspect rendered output.

Consequences

  • Data flow is auditable — reading renderCell tells you exactly which hints reach which chart.
  • Static export and SSR work identically to client render; no context provider to set up.
  • A chart that ignores a forwarded hint fails silently — that’s correct; consumers not wanting shared scales on a particular child simply don’t spread view.
  • Explicit pattern compounds: future shared-view concerns (e.g. shared legend, shared pitch theme) land as new view fields without needing a new context or provider.
← All decisions