Answer the question
In order to leave comments, you need to log in
How to open only one modal window?
When you click on one card-trigger, as many modal windows open as there are card-triggers in the array, but I would like to open one, how can I do this?
var arr = [{src: check, text: "#1111111" },{src: check, text: "#222222"},{src: check, text: "#33333"}]
export default class Menu extends Component {
state = {
modalOpen: false
}
handleOpen = () => this.setState({ modalOpen: true })
handleClose = () => this.setState({ modalOpen: false })
renderCards = () => {
return arr.map((item, i) => {
return(
<Modal open={this.state.modalOpen}
dimmer="inverted"
onClose={this.handleClose}
key={i}
trigger={
<Card onClick={this.handleOpen}>
<Image src={item.src} />
<Text grey medium fontSize="12px">{item.text}</Text>
</Card>}>
<ModalContent data={item.text} onClose={this.handleClose.bind(this)}/>
</Modal>
)
})
}
render(){
return( <Fragment>
{this.renderCards()}
</Fragment> )
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question