1.4.0 • Published 3 years ago

reapex-module-modal v1.4.0

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

Reapex modal module

import { App } from 'reapex'
import modalModule from 'reapex-module-modal'

const app = new App()

// 1. register the module
const modal = app.use(modalModule, '@@modals')

// 2. Create a component to render the modals
const Modals = () => {
  const modals = useSelector(modal.selectors.modals)

  return (
    <div className="reapex-modals">
      {modals.map(m => {
        return m.show ? <m.component key={m.name} {...m.props} /> : null
      })}
    </div>
  )
}

// 3. Render it
<Provider store={store}>
  <Modals />
</Provider>

// show/hide any component
const {show, hide} = modal.useModal('MyDialog')
dispatch(show(MyDialogComponent, props))
dispatch(hide('MyDialog'))
1.4.0

3 years ago

1.2.2

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago