Closed angeloashmore closed 2 years ago
<PrismicText> does not have a way to fallback to a default text value if the given field is falsey (i.e. empty).
<PrismicText>
A prop that renders if the text value of the given field is falsey. The prop could accept a string or any valid React.Element.
React.Element
<PrismicText field={document.data.text_field} fallback="Learn more…" />
To do this today, one must use asText from @prismicio/helpers instead with a {} expression.
asText
@prismicio/helpers
{}
<div> {prismicH.asText(callToActionText) || "Learn more…"} </div>
This isn't terrible, but switching between <PrismicText> and asText is awkward.
N/A
This is implemented in #126.
Is your feature request related to a problem? Please describe.
<PrismicText>
does not have a way to fallback to a default text value if the given field is falsey (i.e. empty).Describe the solution you'd like
A prop that renders if the text value of the given field is falsey. The prop could accept a string or any valid
React.Element
.Describe alternatives you've considered
To do this today, one must use
asText
from@prismicio/helpers
instead with a{}
expression.This isn't terrible, but switching between
<PrismicText>
andasText
is awkward.Additional context
N/A