I have a problem showing a list of buttons where each would display a popup. I have taken react-modal (https://github.com/reactjs/react-modal) component and able to display a single popup on button click, but how would i do it for list of buttons? I ve read about refs collection, but there is seem no way of changing props collection accessing and components by refs name?
Having a show button:
<button type="button" onClick={this.openModal}>Show</button>
openModal function:
openModal: function(ref) {
this.setState({isOpened: true});
}
But how should i set a state value for particular button instance? i can make by giving each isOpened state value particular name: isOpened-1, isOpened-2 and so on, but i guess its not a proper way. Im just learning ReactJS.
true
inopenModal
? – elmeister Oct 1 '16 at 11:26openModal(id, type)
- wheretype
will be one of 'confirm', 'alert' or whatever. Then, you willsetState
with this type and use{this.state.type === popupTypes.alert && ...
inside popup form. – elmeister Oct 1 '16 at 11:43