Socket
Socket
Sign inDemoInstall

react-message-popup

Package Overview
Dependencies
5
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-message-popup

A simple message popup for React


Version published
Weekly downloads
67
decreased by-22.99%
Maintainers
1
Install size
43.2 kB
Created
Weekly downloads
 

Readme

Source

React Message

A simple asynchronous React message popup utility, no needed React Context. So you can use it in anywhere. You just need to install React.

Requirement:

  • React 18
  • React DOM 18

NOTE: If you use React 17, please use version 0.2

How to use

npm i react-message-popup
import { message } from 'react-message-popup'

message.success('成功', 4000)
// etc.

message.loading('Loading...', 4000).then(({ next }) => {
  setTimeout(() => {
    next('成功', 'success')
  }, 2000)
})

message.success('成功', 4000).then(({ destory }) => {
  setTimeout(() => {
    destory()
  }, 2000)
})

Interface

export interface ArgsProps {
  content: string
  duration?: number | null
  key?: string | number
}
type JointContent = ConfigContent | ArgsProps
type ConfigContent = string
type ConfigDuration = number | (() => number)
export interface MessageInstance {
  info(
    content: JointContent,
    duration?: ConfigDuration,
  ): Promise<MessageReturnType>
  success(
    content: JointContent,
    duration?: ConfigDuration,
  ): Promise<MessageReturnType>
  error(
    content: JointContent,
    duration?: ConfigDuration,
  ): Promise<MessageReturnType>
  warning(
    content: JointContent,
    duration?: ConfigDuration,
  ): Promise<MessageReturnType>
  warn(
    content: JointContent,
    duration?: ConfigDuration,
  ): Promise<MessageReturnType>
  loading(
    content: JointContent,
    duration?: ConfigDuration,
  ): Promise<MessageReturnType>
}

export type MessageReturnType = {
  destory(): boolean
  next(message: string, type?: MessageType): void
}

FAQs

Last updated on 11 May 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc