(props: HighlightProps)
| 70 | } |
| 71 | |
| 72 | const Highlight = (props: HighlightProps) => { |
| 73 | const { children, query, styles, caseSensitive } = props; |
| 74 | |
| 75 | if (typeof children !== "string") { |
| 76 | throw new Error("The children prop of Highlight must be a string"); |
| 77 | } |
| 78 | |
| 79 | const chunks = useHighlight({ query, text: children, caseSensitive }); |
| 80 | |
| 81 | return ( |
| 82 | <> |
| 83 | {chunks.map((chunk, index) => |
| 84 | chunk.match ? ( |
| 85 | <Mark key={index} sx={styles}> |
| 86 | {chunk.text} |
| 87 | </Mark> |
| 88 | ) : ( |
| 89 | <Fragment key={index}>{chunk.text}</Fragment> |
| 90 | ), |
| 91 | )} |
| 92 | </> |
| 93 | ); |
| 94 | }; |
| 95 | |
| 96 | export default Highlight; |
nothing calls this directly
no test coverage detected