🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@walltowall/highlighter

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walltowall/highlighter

React component for rendering highlighted words from a string.

latest
npmnpm
Version
0.1.2
Version published
Maintainers
4
Created
Source

Highlighter

React component for rendering highlighted words from a string.

Installation

# npm
npm install @walltowall/highlighter

# yarn
yarn add @walltowall/highlighter

Usage

Supply your searchTerm and the React component you wish to render with renderHighlight for any matched word. The render function will receive the word as its first argument and the current index match as its second argument.

import { Highlighter } from '@walltowall/highlighter'

const Example = () => {
  return (
    <Highlighter
      searchTerm="word"
      renderHighlight={(word, idx) => <em key={idx}>{word}</em>}
    >
      Highlight your desired word! Any word will be wrapped with your
      `renderHighlight`!
    </Highlighter>
  )
}

<Highlighter> children must be a plain string. Providing a component such as a <div> will result in an error.

API

PropRequired?Description
searchTermYesThe word to search for in the provided string.
renderHighlightYesA render prop to render any word match.

Keywords

react

FAQs

Package last updated on 17 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts