# @discovery-solutions/react-modal

> A Super Light Modal for ReactJS and React Native Applications

Latest version **0.0.2** (published 2021-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @discovery-solutions/react-modal
pnpm add @discovery-solutions/react-modal
yarn add @discovery-solutions/react-modal
bun add @discovery-solutions/react-modal
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-07-25 |
| First published | 2021-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lucas Craveiro Paes |
| Maintainers | lucascraveiropaes, l_pascoal, abreu, victorlms |
| Keywords | react, react-hooks, modal, discovery, discovery-solutions |

## Links

- npm: https://www.npmjs.com/package/@discovery-solutions/react-modal
- Repository: https://github.com/discovery-solutions/react-modal
- Homepage: https://github.com/discovery-solutions/react-modal#readme
- Issues: https://github.com/discovery-solutions/react-modal/issues
- npm.io page: https://npm.io/package/@discovery-solutions/react-modal

## Dependencies (1)

- [react-primitives](https://npm.io/package/react-primitives.md) ^0.8.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2021-07-25
- 0.0.1 — 2021-06-21

## README

# Discovery Solutions - React Modal

A Super Light Modal for ReactJS and React Native Applications

```sh
npm i @discovery-solutions/react-modal
```

### Conteúdo

- [Utilização Padrão](#utilização-padrão)

## Utilização Padrão

A primeira coisa a ser feita é instanciar o provider, como no exemplo abaixo.
É possível perceber que existem dois jeitos para declarar os componentes:

```js
import React from "react";
import { ModalProvider, showModal } from "@discovery-solutions/react-modal";
import MyModal from "./MyModal";

const App = () => {
    useEffect(() => {
        setTimeout(() => {
            showModal("test");
        }, 3000);
    }, []);

    return (
        <ModalProvider>
            <MyModal name="test"/> {/* Jeito 1 de declarar */}
            <Modal name="test" component={ MyModal }/> {/* Jeito 2 */}
        </ModalProvider>
    )
}

export default App;
```

A prop ```name``` é **obrigatória** em todos os children do provider. Através dessa flag, que é possível identificar o modal a ser exibido.

E dentro de ```MyModal```, é possível extrair a função para fechar o modal:

```js
import React from "react";

const MyModal = ({ closeModal }) => (
    <div>
        <h1>Testando esse modal</h1>
        <button onClick={ closeModal }>Fechar modal</button>
    </div>
)

export default MyModal;
```

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