Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight match words #26

Open
frontendjorge opened this issue Mar 27, 2019 · 1 comment
Open

Highlight match words #26

frontendjorge opened this issue Mar 27, 2019 · 1 comment

Comments

@frontendjorge
Copy link

is't possible highlight match words with a custom style?

@lesmo
Copy link

lesmo commented Dec 25, 2019

Given that rendering the result is totally in your hands, it should be possible to just check your searchTerms and compare them to do some highlighting while rendering your list.

For example, using react-native-highlight-words and building on the README example:

import Highlighter from 'react-native-highlight-words';

{filteredEmails.map(email => {
  return (
    <TouchableOpacity onPress={()=>alert(email.user.name)} key={email.id} style={styles.emailItem}>
      <View>
        <Highlighter
          highlightStyle={{backgroundColor: 'yellow'}}
          searchWords={[searchTerm]}
          textToHighlight={email.user.name}
        />
        <Highlighter
          style={styles.emailSubject}
          highlightStyle={{backgroundColor: 'yellow'}}
          searchWords={[searchTerm]}
          textToHighlight={email.subject}
        />
      </View>
    </TouchableOpacity>
  )
})}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants