Download react-instantsearch/examples/react-native/src/components/Highlight.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 608 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-instantsearch/examples/react-native/src/components/Highlight.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-instantsearch/examples/react-native/src/components/Highlight.js
-
curl -L -o Highlight.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-instantsearch/examples/react-native/src/components/Highlight.js
608 Bytes
| import React from 'react'; | |
| import { Text } from 'react-native'; | |
| import { connectHighlight } from 'react-instantsearch-native'; | |
| export default connectHighlight( | |
| ({ highlight, attribute, hit, highlightProperty }) => { | |
| const parsedHit = highlight({ attribute, hit, highlightProperty }); | |
| const highligtedHit = parsedHit.map((part, idx) => { | |
| if (part.isHighlighted) { | |
| return ( | |
| <Text key={idx} style={{ backgroundColor: '#ffff99' }}> | |
| {part.value} | |
| </Text> | |
| ); | |
| } | |
| return part.value; | |
| }); | |
| return <Text>{highligtedHit}</Text>; | |
| } | |
| ); | |