From 09df45e9b1dda4678bbab4037aa15f30474a57a7 Mon Sep 17 00:00:00 2001 From: Bokang Huang Date: Sun, 13 Aug 2017 16:32:02 +0800 Subject: [PATCH 1/3] add onSearchWordTap --- index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 1078b8b..c03c554 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ import React, {PropTypes} from 'react'; -import {Text} from 'react-native'; +import {Text, TouchableOpacity} from 'react-native'; import {findAll} from 'highlight-words-core'; Highlighter.propTypes = { @@ -8,7 +8,8 @@ Highlighter.propTypes = { searchWords: PropTypes.arrayOf(PropTypes.string).isRequired, textToHighlight: PropTypes.string.isRequired, sanitize: PropTypes.func, - style: Text.propTypes.style + style: Text.propTypes.style, + onSearchWordTap : PropTypes.func }; /** @@ -22,6 +23,7 @@ export default function Highlighter({ textToHighlight, sanitize, style, + onSearchWordTap, ...props }) { const chunks = findAll({textToHighlight, searchWords, sanitize, autoEscape}); @@ -34,12 +36,14 @@ export default function Highlighter({ return (!chunk.highlight) ? text : ( - - {text} - + onSearchWordTap(text)}> + + {text} + + ); })} From 2528dbe80bc6d7095323b7be93f682bab9b767e3 Mon Sep 17 00:00:00 2001 From: Bokang Huang Date: Sun, 13 Aug 2017 16:50:47 +0800 Subject: [PATCH 2/3] more fixes --- index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index c03c554..60a406f 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ import React, {PropTypes} from 'react'; -import {Text, TouchableOpacity} from 'react-native'; +import {Text} from 'react-native'; import {findAll} from 'highlight-words-core'; Highlighter.propTypes = { @@ -36,14 +36,13 @@ export default function Highlighter({ return (!chunk.highlight) ? text : ( - onSearchWordTap(text)}> - - {text} - - + onSearchWordTap(text)} + style={chunk.highlight && highlightStyle} + > + {text} + ); })} From 2a494e014c0a247feac814e20ca4de0f88ce2913 Mon Sep 17 00:00:00 2001 From: Bokang Huang Date: Sun, 13 Aug 2017 17:03:54 +0800 Subject: [PATCH 3/3] add defaultprops --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 60a406f..6309000 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,10 @@ import React, {PropTypes} from 'react'; import {Text} from 'react-native'; import {findAll} from 'highlight-words-core'; +Highlighter.defaultProps = { + onSearchWordTap : () => {} +} + Highlighter.propTypes = { autoEscape: PropTypes.bool, highlightStyle: Text.propTypes.style,