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

@wenmu/react-notification

v1.0.5

Published

react的一个通知提醒组件

Readme

react-notification

开发一个通知提醒的组件。为了方便扩展,该组件只提供一个空的提醒框,内容完全自定义。避免 !

安装

npm i @wenmu/react-notification --save

效果图

效果图

只是一个提示框,内容自定义。

使用

import ReactNotification from "@wenmu/react-notification";

const notificationObj;
function initNotification() {
  ReactNotification.newInstance(
    { style: { color: "red" }, duration: 3000, autoClose: false },
    (notification) => {
      notificationObj = notification;
      // 如果初始化时就需要显示内容,可以在这调用notice
      // notification.notice({
      //   render: <div style={{ width: "300px", height: "200px" }}>hello</div>,
      // });
    },
  );
}

// 创建一个通知
function createNotice(){
    notification.notice({
        render: <div style={{ width: "300px", height: "200px" }}>hello</div>,
      });
}

function showNotification(){
  notificationObj.show();
}


<button onClick={initNotification}>创建通知</button>;

API

Notification.newInstance(props, (notification) => void) => void

props 详情 |属性名|含义|默认值| |---|---|---| |getContainer|指定通知提醒的容器,一个 html 元素|空| |autoClose|是否自动关闭|true| |duration|自动关闭的时间间隔|4500(毫秒)| |style|设置提醒框容器的内嵌样式,设置提醒框的位置使用这个很方便|空| |className|设置提醒框容器的样式名称|空|

notification.notice(props)

创建一个通知。

props 详情 |属性名|类型|含义| |---|---|---| |render|React.Element|消息内容|

notification.component

消息组件的引用

notification.hidden()

隐藏提醒元素,建议使用这个,使用 destroy 会每次销毁和重建元素,造成资源浪费。

notification.show()

显示通知,内容不发生变化,如果需要显示一个新的通知,需要使用 notice。

notification.destroy()

销毁提醒元素

使用技巧

该组件提供了灵活的配置,可扩展性较强,满足各种需求;

初始化不显示

如果初始化时,不想显示提醒框,可以通过设置 style 的来实现

ReactNotification.newInstance(
  { style: { display: "none" }, duration: 3000, autoClose: false },
  (notification) => {
    notificationObj = notification;
  },
);

当使用 notice()方法添加消息时,会自动显示提醒框。不需要调用 show()方法。

自定义提醒框的位置

使用 style 也可以设置弹框的位置;