# ez-modal-react

> a easy modal state manager for React.

Latest version **1.0.5** (published 2024-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install ez-modal-react
pnpm add ez-modal-react
yarn add ez-modal-react
bun add ez-modal-react
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-09-26 |
| First published | 2023-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 36 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Author | raotaohub |
| Maintainers | raotaohub |
| Keywords | react modal, modal store, modal manager, modal state manager |

## Links

- npm: https://www.npmjs.com/package/ez-modal-react
- Repository: https://github.com/raotaohub/ez-modal-react
- Homepage: https://raotaohub.github.io/ez-modal-react-book/
- Issues: https://github.com/raotaohub/ez-modal-react/issues
- npm.io page: https://npm.io/package/ez-modal-react

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2024-09-26
- 2.0.0-alpha.0 (alpha) — 2026-07-19
- 1.0.6-alpha.0 — 2026-07-18
- 1.0.4 — 2024-02-27
- 1.0.2 — 2024-01-11
- 1.0.1 — 2024-01-07
- 1.0.0 — 2024-01-06
- 0.0.9 — 2023-10-17
- 0.0.8 — 2023-09-28
- 0.0.7 — 2023-07-23
- 0.0.6 — 2023-06-14
- 0.0.5 — 2023-06-12
- 0.0.4 — 2023-05-28
- 0.0.3 — 2023-05-27
- 0.0.2 — 2023-05-27
- … 1 more at https://npm.io/package/ez-modal-react/versions

## README

![ez-modal-scenario](assets/idea.png)

<p><h4 align='center'>ez modal react</h4></p>

<span style="margin-left:32px">The</span> concept of EasyModal is simple: to treat the operations of modals as asynchronous events, managing their lifecycle through Promises. It also provides type inference and constraints.

<p align='center'>English | <a href='./README.zh-CN.md'>简体中文</a> </p>

<p align="center">
<a href="https://www.npmjs.com/package/ez-modal-react" target="__blank"><img src="https://img.shields.io/npm/v/ez-modal-react?color=2B90B6&label=" alt="NPM version"></a>
<a href="https://www.npmjs.com/package/ez-modal-react" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/ez-modal-react?color=349dbe&label="></a>
<a href="https://raotaohub.github.io/ez-modal-react-book/en-US" target="__blank"><img src="https://img.shields.io/static/v1?label=&message=docs&color=45b8cd" alt="Docs & Demos"></a>
<a href="https://raotaohub.github.io/ez-modal-react-book/en-US" target="__blank"><img src="https://img.shields.io/static/v1?label=&message=demos&color=4ec5d4" alt="Themes"></a>
</p>

## ✨ Feature

1. Based on **Promise**,In addition, there is no need to manage the switch status, which can reduce the tedious status management.
2. Supports **<a href="#typeinfer" title="">return value type inference</a>**,elevate the development experience.
3. Small size(~1kb after gzip)、easy access non-intrusive、support any UI library.

## 🔨 Documentations

[中文文档](https://raotaohub.github.io/ez-modal-react-book) | [English](https://raotaohub.github.io/ez-modal-react-book/en-US)

[Example](https://raotaohub.github.io/ez-modal-react-book/example) | [codesandbox](https://codesandbox.io/p/sandbox/confident-shape-rt7bzr?embed=1)

## 📦 install

```shell
# with yarn
yarn add ez-modal-react -S

# or with npm
npm install ez-modal-react -S
```

## 🚀 Examples

1. **use EasyModal Provider**

```tsx
import EasyModal from 'ez-modal-react';

ReactDOM.render(
    <EasyModal.Provider> // wrap your main Componet
      <App />
    </EasyModal.Provider>
  document.getElementById('root'),
);
```

2. **create modal**

```tsx
import EasyModal, { InnerModalProps } from 'ez-modal-react';

interface IProps extends InnerModalProps<'modal'> {
  age: number;
  name: string;
}

const InfoModal = EazyModal.create((props: IProps) => (
  <Modal
    open={props.visible}
    //(property) hide: (result: 'modal') => void ts(2554)
    onOk={() => props.hide('modal')}
    onCancel={() => props.hide(null)}
    afterClose={props.remove}
  >
    <h1>{props.age}</h1>
    <h1>{props.name}</h1>
  </Modal>
));
```

3. **anywhere use it**

```tsx
// "The property 'age' is missing in the type '{ name: string; }'... ts(2345)"
const res = await EasyModal.show(InfoModal, { age: 10 });
console.log(res); // modal
```

## Acknowledgement

1. fhd Inc @xpf
2. [nice-modal-react](https://github.com/eBay/nice-modal-react)
3. Thanks to [SevenOutman (Doma)](https://github.com/SevenOutman) repository building support, I consulted his [aplayer-react](https://github.com/SevenOutman/aplayer-react) project

## LICENSE

[MIT](https://github.com/raotaohub/ez-modal-react/blob/main/LICENSE)

---

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