# react-popup-components

> A React pop-up component library

Latest version **1.2.2** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-popup-components
pnpm add react-popup-components
yarn add react-popup-components
bun add react-popup-components
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2023-11-07 |
| First published | 2023-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | lhq |
| Maintainers | lllhq |
| Keywords | react, popup-component, alert, toast, confirm |

## Links

- npm: https://www.npmjs.com/package/react-popup-components
- Repository: https://github.com/011015/react-popup-components
- Homepage: https://011015.github.io/react-popup-components
- Issues: https://github.com/011015/react-popup-components/issues
- npm.io page: https://npm.io/package/react-popup-components

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2023-11-07
- 1.2.1 — 2023-11-06

## README

<div align="center">
<h1 align="center">react-popup-components</h1>
一款 React 弹窗组件库

![npm](https://img.shields.io/npm/v/react-popup-components)
![license](https://img.shields.io/github/license/011015/react-popup-components)
![language](https://img.shields.io/github/languages/top/011015/react-popup-components)
![last](https://img.shields.io/github/last-commit/011015/react-popup-components)

<a href="https://011015.github.io/react-popup-components/index.html" target="_blank">在线体验</a>

</div>

## 安装

`npm install react-popup-components`

注意：必须先安装 React ，`npm install react`

## Alert

#### 代码演示

```react
import { alert } from 'react-popup-components'
function Test() {
    const [ alertApi, alertContext ] = alert.useMessage();
    const handle = () => {
        alertApi.info({
            title: 'title',
            content: 'content',
            fn() {
                alertApi.close();
            }
        });
    }
    return (
        <>
        	<h1>Alert</h1>
        	<button onClick={handle}>click</button>
        	{alertContext}
        </>
    );
}
export default Test
```

#### API

##### 传递信息方法

- `alertApi.info(config)`

`config`对象属性如下：

| 参数    | 说明                 | 类型     | 默认值 |
| ------- | -------------------- | -------- | ------ |
| title   | 提示标题             | string   | -      |
| content | 提示内容             | string   | -      |
| fn      | 点击确认后的回调函数 | function | -      |

##### 关闭窗口方法

- `alertApi.close()`（默认点击确认后会关闭）

## Confirm

#### 代码演示

```react
import { confirm } from 'react-popup-components'
function Test() {
    const [ confirmApi, confirmContext ] = confirm.useMessage();
    const handle = () => {
        confirmApi.info({
            title: 'title',
            content: 'content',
            fn() {
                confirmApi.close();
            }
        });
    }
    return (
        <>
        	<h1>Confirm</h1>
        	<button onClick={handle}>click</button>
        	{confirmContext}
        </>
    );
}
export default Test
```

#### API

##### 传递信息方法

- `confirmApi.info(config)`

`config`对象属性如下：

| 参数    | 说明                 | 类型     | 默认值 |
| ------- | -------------------- | -------- | ------ |
| title   | 提示标题             | string   | -      |
| content | 提示内容             | string   | -      |
| fn      | 点击确认后的回调函数 | function | -      |

##### 关闭窗口方法

- `confirmApi.close()`（默认点击确认后会关闭）

## Toast

#### 代码演示

```react
import { toast } from 'react-popup-components'
function Test() {
    const [ toastApi, toastContext ] = toast.useMessage();
    const handle = () => {
        toastApi.info('content');
    }
    return (
        <>
        	<h1>Confirm</h1>
        	<button onClick={handle}>click</button>
        	{toastContext}
        </>
    );
}
export default Test
```

#### API

##### 传递信息方法

- `toastApi.info(content)`

| 参数    | 说明     | 类型   | 默认值 |
| ------- | -------- | ------ | ------ |
| content | 提示内容 | string | -      |

---
_Source: https://npm.io/package/react-popup-components · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
