ChoiceFormatter
This is a React component

Source
import { ChoiceFormatter } from "@prestojs/ui";
ChoiceFormatter(props)

Render the label for choice based on the provided value

This is the default formatter used when a field has choices defined.

ParameterTypeDescription
props.blankLabelReactNode

What to render when value is null or undefined

*props.choices[any, string][]|Map

The choices to render. This can be a Map of value to label or an array of 2-element arrays [value, label].

props.invalidChoiceLabelReactNode

What to render if value is not found in choices. By default this is considered a programming error and a warning is logged. If your use case supports invalid values pass warnOnInvalidChoice={false} to suppress the warning.

*props.valueT

The value to format

props.warnOnInvalidChoiceboolean

If value is not found in choices then a warning will be logged by default. To supress this warning pass warnOnInvalidChoice={false}.

Defaults to true.

Examples