Answer the question
In order to leave comments, you need to log in
Modal window in map() react js?
help me please. I don't understand how to open a modal window with elements. There is an array that generates a different number of elements in the component (from 4 to 10) and for each there should be a modal viewer window. I use map() to create the required number of elements, and then...
<div className="general">
{this.props.filteredBooks.map((item, index) =>
<div className="book-item" key={index}>
<div className="size-bg" onClick={this.openModal}>
<img src={item.Image}/>
</div>
<h3>{item.Name}</h3>
<p>{item.Author}</p>
<div className="rating" key={index}>
<img src={item.ImageRating} />
</div>
<Modal
isOpen={this.state.modalIsOpen}
ariaHideApp={false}
onRequestClose={this.handleCloseModal}
className="Modal"
overlayClassName="Overlay"
>
<div className="image-modal">
<img src={item.Image}/>
</div>
<button onClick={this.closeModal}>Закрыть модальное окно</button>
</Modal>
</div>
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