I am new in Gatsby and trying to place a image carousel on a modal. I have an array of images on Contentful and cannot map the images. I can do it outside of the modal but inside I can't reach to the array .
I tried to use different modals, different carousels but this is the best result that I can find.
These are the codes for carousel:
const CarouselUI = ({ position, handleClick, children }) => (
<Container>
{children}
<Arrow onClick={handleClick} data-position={position - 1}>{'<'}</Arrow>
<Arrow right onClick={handleClick} data-position={position + 1}>{'>'}</Arrow>
</Container>
);
const Carousel = makeCarousel(CarouselUI)
These are the codes for component
const Product = ({ node }) => {
const [showModal, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
return (
<div>
<figure>
<Link href="/">
<Image fluid={node.image.fluid} alt={node.title} />
</Link>
<figcaption onClick={handleShow}>
<h4>Quick View</h4>
</figcaption>
<p>{node.title}</p>
<p>{node.price}</p>
<Modal className={product1Style.Modal} show={showModal} onHide={handleClose}>
<section className={product1Style.modalheader}>
<h1>{node.title}</h1>
</section>
<section className={product1Style.modalcontent}>
<Modal.Body className={product1Style.row + ' ' + product1Style.center} closeButton>
<div className={product1Style.col + ' ' + product1Style.colspan3}>
<h4>{node.price}</h4>
<div>
<button>Purchase</button>
</div>
</div>
<div className={product1Style.col + ' ' + product1Style.colspan4}>
<Carousel>
{node.images.map((nod) => {
return (
<Slide>
<Image fluid={nod.images.fluid} />
</Slide>
)
})}
</Carousel>
</div>
</Modal.Body>
</section>
</Modal>
</figure>
</div>
)
}
And this is my class:
class Product1 extends React.Component {
render() {
const ProductNecklace = this.props.data.productNecklace.edges
return (
<Layout>
<section className={product1Style.lowerBody}>
<section className={product1Style.product1Necklace}>
<h3>Product1 Necklace</h3>
<div className={product1Style.productnecklaceimage}>
{ProductNecklace.map(({ node }, i) => (
<Product node={node} key={node.id} />
))}
</div>
</section>
</section>
</Layout>
)
}
}