redux-react-modals

1.3.1 • Public • Published

redux-react-modals

** EN CONSTRUCTION ** Ce code est du code externalisé du https://github.com/betagouv/pass-culture-shared qui concentre un nombre d'utilités React Redux utilisé par les applications front du pass culture. Tant que les tests fonctionnels ne sont pas écrits, cette lib ne peut être considérée en production.

Basic Usage

You need to add first the modals reducer in your root reducer:

import { modals } from 'redux-react-modals'
import { combineReducers } from 'redux'
 
const rootReducer = combineReducers({
  ...
  modals,
})
 
const store = createStore(rootReducer)

Then the lib provides a Modal component and some redux actions, like:

import React, { Fragment } from 'react'
import { Modal, showModal } from 'redux-react-modals'
 
class Foo extends Component {
 
  onShowModalClick = () => {
    const { dispatch } = this.props
    dispatch(showModal('foo', <div> Hello! </div>))
  }
 
  render () {
    const { query } = this.props
    const { counter } = query.parse()
    return (
      <Fragment>
        <button onClick={this.onShowModalClick} />
          Show Modal
        <button>
        <Modal />
      </Fragment>
    )
  }
}
 
export default connect()(Foo)

Readme

Keywords

Package Sidebar

Install

npm i redux-react-modals

Weekly Downloads

4

Version

1.3.1

License

MPL-2.0

Unpacked Size

36.3 kB

Total Files

13

Last publish

Collaborators

  • ledoux