redux-awesome-modal
A redux Modal component which allows you to pass props to the modal child.
Usage
;;;;
Create A Modal Component
{ //Access props passed down from the Modal component const count = thisprops; return <div style=padding: "16px 24px">count</div> }
Add it to your reducers
; ;
Add the modal from the library to your Root App
const mapAppStateToProps = { const modal = state; return modal ;}; const App = Component { const modal = thisprops; console; // pass props to modal children.. the second argument of show_modal, you can also pass methods to change redux state // hide_modal is the third argument which will close the modal on overlay_click // you can do some other stuff with the 3rd argument before closing hide_modal return <div> <button onClick={ return thisprops }> Show Modal </button> thispropschildren <Modal ...modal modal_components= "modal_one" : MyModalComponent "modal_two" : MyOtherModalComponent ... /> </div>; } ;
API
modal_components -- Define an object which maps a String to a Modal . This will define which modal to show when show_modal action is fired.
show_modal - Takes 3 arguments, modal_type (String), modal_props (Props for the component which the Modal Renders), on_overlay_click (Function. Function that is fired when the overlay is clicked on)