concrete/render/unrenderable
A placed instance throws when it is rendered over a fixture.
A placed instance throws when it is rendered over a fixture.
Graded by the render stage of concrete check, in the render venue. A violation reports this id and the file it failed at — see every rule and concrete check.
Reason
The render stage runs every placed instance over every fixture and over a synthesized empty per slot — the state where that one slot has no value and everything else does. The pipeline puts your render function in the platform's hands: it is called with whatever content exists at the time, including none, and a throw there is a blank page in the editor or a failed publish. The empty states are the ones no fixture covers, which is why they are synthesized for you.
Fix
Render from the bindings and never assume a value. Branch on present, map over
bindItems(...) instead of indexing into it, and drop the non-null assertions — an empty
list really is empty in one of the states this stage renders.
Before and after
import { bindItems, fact, list, number, object, row, Section, section, Slot, text } from "@homepages/concrete";
export const Units = section(
{
key: "units",
label: "Units",
slots: {
rows: list({
label: "Units",
source: fact.property.units,
item: (el) => {
const unit = row({ label: "Unit", from: fact.property.units, source: el });
return object({
fields: {
unit,
name: text.short({ label: "Unit", source: unit.label }),
beds: number({ label: "Beds", source: unit.beds }),
},
});
},
}),
},
},
({ slot }) => (
<Section>
{/* The synthesized empty renders this with no rows at all. */}
<Slot.Text slot={bindItems(slot.rows)[0]!.name} as="h2" />
</Section>
),
);import { bindItems, fact, list, number, object, row, Section, section, Slot, text } from "@homepages/concrete";
export const Units = section(
{
key: "units",
label: "Units",
slots: {
rows: list({
label: "Units",
source: fact.property.units,
item: (el) => {
const unit = row({ label: "Unit", from: fact.property.units, source: el });
return object({
fields: {
unit,
name: text.short({ label: "Unit", source: unit.label }),
beds: number({ label: "Beds", source: unit.beds }),
},
});
},
}),
},
},
({ slot }) => (
<Section>
<Slot.List slot={slot.rows} as="ul">
{bindItems(slot.rows).map((item) => (
<Slot.Object key={item.index} slot={item} as="li">
<Slot.Text slot={item.name} as="h2" />
<Slot.Number slot={item.beds} as="p" />
</Slot.Object>
))}
</Slot.List>
</Section>
),
);