MCPcopy Create free account
hub / github.com/shoutem/ui / TextElement

Function TextElement

html/elements/Text.js:40–57  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

38}
39
40export function TextElement(props) {
41 // Remove empty white space lines used just to move element in new line.
42 // Use "p" or "br" to add new line.
43 const textualChildElements = decodeHtmlEntities(
44 removeWhiteSpace(props.childElements),
45 );
46
47 if (textualChildElements.length === 0) {
48 // Even if there is no children to render, the Text must be rendered
49 // because otherwise RN may render a View to wrap a "null" which may lead to
50 // a case where a View is in the Text.
51 return <Text style={{ height: 0 }} />;
52 }
53
54 // Must be the RN Text so that style inheritance chain
55 // doesn't break with additional layer.
56 return <Text {...props}>{textualChildElements}</Text>;
57}
58
59TextElement.propTypes = {
60 ...ElementPropTypes,

Callers

nothing calls this directly

Calls 2

removeWhiteSpaceFunction · 0.85
decodeHtmlEntitiesFunction · 0.70

Tested by

no test coverage detected