import * as React from 'react' export default class Highlight extends React.PureComponent{ render() { if (!this.props.search || this.props.search === '') { return (
{this.props.label}
); } return ( {this.props.label.split(this.props.search) .reduce((prev, current, i) => { if (!i) { return [current]; } return prev.concat({this.props.search}, current); }, []) } ); } }