UNPKG

519 BJavaScriptView Raw
1import React, {
2 PropTypes,
3} from 'react';
4
5import {
6 Text,
7} from 'react-native';
8
9function StringToText(props) {
10 const { children } = props;
11 if (typeof children === 'string') {
12 return <Text {...props} />;
13 }
14 return children;
15}
16
17StringToText.propTypes = {
18 children: PropTypes.oneOfType([
19 PropTypes.element,
20 PropTypes.string,
21 ]),
22};
23StringToText.defaultProps = {
24 children: null,
25};
26
27StringToText.isText = text => typeof text === 'string' || text.type === Text;
28
29export default StringToText;
30
\No newline at end of file