npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-markkeyword

v1.0.9

Published

react-native 高亮关键字

Readme

react-native 巧用正则 和split() 在Text组件标红显示关键字

说明

有人问在群里问到,我搜索的关键字怎么高亮显示在我搜索的那个字符里面,当时第一反应很简单。 确实在html页面是很简单一个replace( )方法就搞定了,但是在react-native中就不行, 因为字符串文本必须放在 Text组件中。 我想大概两个方法:

1,就通过html 的形势,replace( )替换,然后通过vebView以字符串的形式噻进去,这个方式没啥子说的。 2,还是通过Text组件来放字符,只不过要处理分割出关键字和非关键字然后给他们装在不同的Text组件中,现在我就实现 这一种。

集成方式

npm i react-native-markkeyword

使用

import markKeyWord from 'react-native-markkeyword';

<markKeyWord
    markBoxStyle={{flexDirection: 'row'}}//文本父级View样式非必填
    markActiveStyle={{color:'red'}}//标记key的颜色
    markItemStyle={{color:'#999'}} //未标记的文本的颜色
    //需要被标记的字符串
    searchStr={'我搜索的关键字怎么高亮显示在我搜索的那个字符里面'}
    //关键字数组,高亮显示的文字数组
    keyArr={['我','关键字','字符']}
    >