// @flow import * as React from 'react'; import autobind from 'autobind-decorator'; import fuzzySort from 'fuzzysort'; import { fuzzyMatch } from '../../../common/misc'; type Props = {| search: string, text: string, |}; @autobind class Highlight extends React.PureComponent { render() { const { search, text, ...otherProps } = this.props; // Match loose here to make sure our highlighting always works const result = fuzzyMatch(search, text, { splitSpace: true, loose: true }); if (!result) { return {text}; } return ( ', '', ), }} /> ); } } export default Highlight;