New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-deep-match

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-deep-match

a deep regex match component for react

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

React-deep-match

🔍 A deep regex match component for react, support reactNode match.

React-deep-match support regular expression matches in a reactDom or a string; and wrap each match a react node, also support custom wrap;

See the demo

How To Use

For example:

import DeepMatch from 'react-deep-match';

<DeepMatch text='testvalue' find="test" />
// result:
<div><span class="matched">test</span>value</div>

Also component support reactNode deep Match

<DeepMatch
text={<p>
  <div>testvalue</div>
  <span>valuetest2</span>
</p>}
find="test"
/>
// result:
<div>
  <p>
    <div><span class="matched">test</span>value</div>
    <span>value<span class="matched">test</span>2</span>
  </p>
</div>

And component support Regex match, and custom match wrap;

<DeepMatch
  text={<p>
    <span>testvalue123test</span>
  </p>}
  find={/[0-9]/g}
  wrap={(matched) => {
    return <i class="number">{matched}</i>;
  }}
/>
// result:
<div><p>
  <span>testvalue<i class="number">{123}</i>test</span>
</p></div>

Installation

npm install react-deep-match --save

import DeepMatch from 'react-deep-match';

API

Reac-deep-match supports these props;

  • text(string | ReactNode): Text or ReactNode, you want to search for
  • find(string | RegExp): Text or a RegExp, the rules you want to match text
  • wrap((match: string, index: string) => string | React.ReactNode): A Function, you want to wrap your matched texts, argument is the matched text

padolsey/findAndReplaceDOMText - 🔍 Find and replace DOM text

License

MIT

Keywords

react-deep-match

FAQs

Package last updated on 04 Jun 2018

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