File size: 765 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import React from 'react';
import { Text } from 'react-native';
import { connectHighlight } from 'react-instantsearch-native';

export default connectHighlight(
  ({ highlight, attribute, hit, highlightProperty, inverted }) => {
    const parsedHit = highlight({ attribute, hit, highlightProperty });
    const styles = inverted ? {} : { backgroundColor: '#ffff99' };
    const highligtedHit = parsedHit.map((part, idx) => {
      if (part.isHighlighted)
        return (
          <Text key={idx} style={styles}>
            {part.value}
          </Text>
        );
      return (
        <Text key={idx} style={{ fontWeight: inverted ? 'bold' : 'normal' }}>
          {part.value}
        </Text>
      );
    });
    return <Text>{highligtedHit}</Text>;
  }
);