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