2.0.1 • Published 6 years ago

react-redux-dialog v2.0.1

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

react-redux-dialog

Travis npm Coveralls

Gracefully handle presenting Modal Dialogs via Redux. Leverages react-modal.

Installation

npm i -S react redux react-redux react-redux-dialog

Usage

Mount the reducer

The reducer must be mounted at 'modal'.

import { combineReducers } from 'redux';
import { reducer as modal } from 'react-redux-dialog';

export default combineReducers({ 
    modal,
    // ... other reducers
})

Mount the container

import { ModalContainer } from 'react-redux-dialog';
class App extends React.Component {
	render() {
		return (
			<div>
			    <ModalContainer />
			    {/* ... the rest of your component */}
            		</div>
		)
	}
}

Dispatch a modal via setModal

import { setModal } from 'react-redux-dialog';

setModal(AnyComponent, {
    componentProps: { /* Props your AnyComponent uses */ },
    modalProps: { ... }
})

And that's it! The ModalContainer will take care of the rest.

modalProps

PropertytypeRequired?Description
titlestringnoA title for the modal, that will appear in the header
showCloseboolean=falsenoShow a close button for the modal

Additionally any other valid prop that react-modal uses will be passed along to the internal Modal.

2.0.1

6 years ago

2.0.0

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago