2.0.0-alpha.0 • Published 1 year ago

react-message-popup v2.0.0-alpha.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

React Message

npm.io

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
}
1.1.1

1 year ago

1.1.0

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

2.0.0-alpha.0

1 year ago

1.0.0

2 years ago

1.0.0-alpha.4

2 years ago

1.0.0-alpha.3

2 years ago

0.3.0

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.0-alpha.0

2 years ago

0.2.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago