# react-modalz

> Simple, straight foward react/redux modal.

Latest version **0.0.92** (published 2019-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-modalz
pnpm add react-modalz
yarn add react-modalz
bun add react-modalz
```

## 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.92 |
| Published | 2019-05-30 |
| First published | 2019-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 27.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Willian Assis |
| Maintainers | willianassis |
| Keywords | react, modal, redux |

## Links

- npm: https://www.npmjs.com/package/react-modalz
- Repository: https://github.com/willianassis/react-modalz
- Homepage: https://github.com/willianassis/react-modalz#readme
- Issues: https://github.com/willianassis/react-modalz/issues
- npm.io page: https://npm.io/package/react-modalz

## 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.92 (latest) — 2019-05-30
- 0.0.91 — 2019-05-30
- 0.0.9 — 2019-05-30
- 0.0.8 — 2019-05-30
- 0.0.7 — 2019-05-30
- 0.0.6 — 2019-05-30
- 0.0.3 — 2019-05-29
- 0.0.2 — 2019-05-28

## README

# React-Modalz

Easy, fast, straight foward react/redux modal.

##### !!! This lib has Redux-Thunk as middleware dependency. !!!
#
### Installation
```sh
$ npm install react-modalz
$ yarn add react-modalz
```

### Usage example
import deps
> index.js
```sh
import thunk from 'redux-thunk'
import { Provider } from 'react-redux'
import { createStore, applyMiddleware } from 'redux'
import rootReducer from './rootReducer'

const store = applyMiddleware(thunk)(createStore)(rootReducer)
```

> index.js
```sh
<Provider store={store}>
	<App />
</Provider>
```

Place the Modalz component at your 'root' so it can be called gloabally between all components.
> app.js
```sh
import React from 'react'
import { Modalz, ModalzActions } from 'react-modalz/lib'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'

function App(props) {
  return (
    <div className="App">
      <button onClick={() => props.modalzOpen(<Component userId={1} />)}>Open Modal</button>
      <Modalz />
    </div>
  );
}

function Component(props) {
  return (
    <div>
      Heres is you component inside Modalz Body. // {props.userId}
    </div>
  )
}

const mapState = state => ({ modalz: state.modalz })
const mapDispatch = dispatch => bindActionCreators({ modalzOpen: ModalzActions.modalzOpen }, dispatch)

export default connect(
  mapState,
  mapDispatch
)(App)
```

Finally in your rootReducer file
> rootReducer.js
```sh
import { combineReducers } from 'redux'
import { ModalzReducers } from 'react-modalz/lib'

export default combineReducers({
  modalz: ModalzReducers
})
```

### Redux Actions

| Action | Args | Ex: |
| ------ | ------ | ------ |
| modalzOpen | Component | props.modalzOpen(<Component {...compProps } />) |
| modalzClose | | props.modalzClose() |
| modalzUpdate | Object | props.modalzUpdate({ ... }) |

### modalzUpdate method
Here you can update the modal config. ex:

```sh
useEffect(() => {
  props.modalzUpdate({
    title: 'modal title here.'
  })
}, [])
```

#### modalzUpdate object props
| Prop | Type |
| ------ | ------ |
| isOpen | Boolean |
| content | Component |
| onCancel | Function |
| onConfirm | Function |
| btnCancelText | String |
| btnCancelClass | String |
| btnConfirmText | String |
| btnConfirmClass | String |

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