getFormatterForField
Sourceimport { getFormatterForField } from "@prestojs/ui";
getFormatterForField(field)
Returns the default formatter for a given Field.
This can be called directly but is more commonly used via UiProvider and FieldFormatter.
Depending on Field, this will return either a Formatter component directly, or [Formatter, props] where props is the default props that would be applied to said formatter.
NOTE The formatter components here are loaded using React.lazy. Your build must support this otherwise it is recommended to implement your own version (you can copy this implementation as a starting point).
If you are using nextjs React.lazy is not supported - you can switch it out for
next/dynamic
.
Parameter | Type | Description | |
---|---|---|---|
* | field | Field |
Returns
One of the following:
React.ComponentTypeOR
[React.ComponentType, Record]OR
stringOR
null