JSPM

redux-modal-container

0.3.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q23755F
  • License MIT

Manage modals in applications that are using react and redux.

Package Exports

  • redux-modal-container

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-modal-container) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Redux-Modal-Container

Build Status redux-modal-container codecov

This library provides an easy way to show and hide modals when working with Redux.

Installation

To install the latest version:

npm install --save redux-modal-container

or

yarn add redux-modal-container

How to use

Create the modals entry point (Container component needs access to the Redux state):

import { Container as ModalContainer } from 'redux-modal-container';
// ...
render(
  <Provider store={yourStore}>
    <ModalContainer 
      modals={{
        simple: () => <div>Modal 1</div>,
      }}
    />
    <MyComponent />
  </Provider>,
  document.findElementById('root')
)

Combine the modal reducer:

import { modalReducer } from 'redux-modal-container';
// ...
export const rootReducer = combineReducers({
  modals: modalReducer,
});

Trigger the modal from your connected component:

import { showModal } from 'redux-modal-container';
// ...

class MyComponent extends React.Component {
  trigger = () => {
    this.props.showModal('simple');
  };
  render() {
    return (
      <div>
        <button onClick={this.trigger}>Open modal</button>
      </div>
    );
  }
}

export default connect(null, dispatch =>
  bindActionCreators({ showModal }, dispatch),
)(MyComponent);

A full example can be found in examples directory.

License

MIT