Skip to content

Commit 24ad5c0

Browse files
authored
Merge pull request #66 from n-sviridenko/patch-1
Fix importing Text from react-native
2 parents 228a893 + f62f2ac commit 24ad5c0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/ParsedText.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import ReactNative from 'react-native';
2+
import { Text } from 'react-native';
33
import PropTypes from 'prop-types';
44

55
import TextExtraction from './lib/TextExtraction';
@@ -11,12 +11,12 @@ export const PATTERNS = {
1111
};
1212

1313
const defaultParseShape = PropTypes.shape({
14-
...ReactNative.Text.propTypes,
14+
...Text.propTypes,
1515
type: PropTypes.oneOf(Object.keys(PATTERNS)).isRequired,
1616
});
1717

1818
const customParseShape = PropTypes.shape({
19-
...ReactNative.Text.propTypes,
19+
...Text.propTypes,
2020
pattern: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)]).isRequired,
2121
});
2222

@@ -25,11 +25,11 @@ class ParsedText extends React.Component {
2525
static displayName = 'ParsedText';
2626

2727
static propTypes = {
28-
...ReactNative.Text.propTypes,
28+
...Text.propTypes,
2929
parse: PropTypes.arrayOf(
3030
PropTypes.oneOfType([defaultParseShape, customParseShape]),
3131
),
32-
childrenProps: PropTypes.shape(ReactNative.Text.propTypes),
32+
childrenProps: PropTypes.shape(Text.propTypes),
3333
};
3434

3535
static defaultProps = {
@@ -63,7 +63,7 @@ class ParsedText extends React.Component {
6363

6464
return textExtraction.parse().map((props, index) => {
6565
return (
66-
<ReactNative.Text
66+
<Text
6767
key={`parsedText-${index}`}
6868
{...this.props.childrenProps}
6969
{...props}
@@ -73,13 +73,13 @@ class ParsedText extends React.Component {
7373
}
7474

7575
render() {
76-
// Discard custom props before passing remainder to ReactNative.Text
76+
// Discard custom props before passing remainder to Text
7777
const { parse, childrenProps, ...remainder } = { ...this.props };
7878

7979
return (
80-
<ReactNative.Text ref={ref => (this._root = ref)} {...remainder}>
80+
<Text ref={ref => (this._root = ref)} {...remainder}>
8181
{this.getParsedText()}
82-
</ReactNative.Text>
82+
</Text>
8383
);
8484
}
8585
}

0 commit comments

Comments
 (0)