MCPcopy
hub / github.com/formatjs/formatjs / FormattedPlural

Function FormattedPlural

packages/react-intl/components/plural.tsx:22–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22const FormattedPlural: React.FC<Props> = props => {
23 const {formatPlural, textComponent: Text} = useIntl()
24 const {value, other, children} = props
25
26 const pluralCategory = formatPlural(value, props)
27 const formattedPlural = props[pluralCategory as 'one'] || other
28
29 if (typeof children === 'function') {
30 return children(formattedPlural)
31 }
32 if (Text) {
33 return <Text>{formattedPlural}</Text>
34 }
35 // Work around @types/react where React.FC cannot return string
36 return formattedPlural as any
37}
38
39FormattedPlural.displayName = 'FormattedPlural'
40

Callers

nothing calls this directly

Calls 2

formatPluralFunction · 0.85
useIntlFunction · 0.70

Tested by

no test coverage detected