Comments (3)
For this you may save the searchKey into state using setState and pass this searchkey to the searchWords props of Highlighter like this example below:
This is your text input to enter the search keyword:
<TextInput placeholder='Search for initials' onChangeText={(text)=>{this.setState({searchKey: text})}} />
And your Highlighter component would look like this
<Highlighter
highlightStyle={{backgroundColor:'yellow'}}
searchWords={[this.state.searchKey]}
textToHighlight='Your text goes here.....'
/>
from react-native-highlight-words.
@MohiniGupta04 I'm still not clear how your comment resolves the issue @ramisalem described. I just found this package but I only want to try and highlight an exact match, not partial matches within a longer word... Any solutions?
from react-native-highlight-words.
I just figured out how accomplish using the code below. (I'm using lodash)
<TextInput
ref={_input}
onChangeText={onChangeValue}
multiline
placeholderTextColor={Colors.darkGrey}
autoCapitalize="none"
style={styles.textInput}
placeholder={
state.editComment
? 'Update comment...'
: 'Write a comment...'
}>
{_.flatMap(
value.split(' ').map((word: string) => {
if (state[articleID].blacklistedWords[word]) {
return (
<Text style={styles.highlightStyle}>{word}</Text>
);
} else {
return <Text>{word}</Text>;
}
}),
(word, index, array) =>
array.length - 1 !== index // .join(" ") throws [Object, object] so manually add spaces between array elements
? [word, <Text> </Text>]
: word,
)}
</TextInput>
from react-native-highlight-words.
Related Issues (20)
- Implement to <Textarea>
- How can we add Padding and other styles into highlighted words? HOT 2
- Is it possible to set property of Text components like numberOfLines, ellipsizeMode to Highlighter HOT 1
- Add multiple styles to other words HOT 1
- Release new version
- how to get total count of highlighted word. HOT 1
- buf if word start with "+" char HOT 6
- Please add autoEscape={true} in README HOT 1
- Scrollto highlight word
- input '.' and it will all be highlighted HOT 1
- Text strings must be rendered within a <Text> component
- chore: add ts support HOT 1
- Can we add onPress for highlight text? HOT 1
- Any way to add an ellipses effect to the text passed to the highlighter? HOT 1
- warning " > [email protected]" has incorrect peer dependency "react@^15.5.0". HOT 3
- Update the package to use deprecated-react-native-prop-types and keep compatibility with react native 0.69.x HOT 1
- ERROR TypeError: undefined is not an object (evaluating '_reactNative.Text.propTypes.style') in react native 0.70 HOT 1
- Is this package still be maintained? HOT 1
- Expose React Native <Text/> props to highlighted words HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-highlight-words.