I have a caroussel using react-slick and I want the main slide to take the same width as another component and being responsive.
I tried to calculate it like this:
const width = (window.innerWidth - document.getElementById('element').offsetWidth)/2;
In my render method I have:
const settings = {
className: "center",
centerMode: true,
arrows: true,
infinite: true,
centerPadding: "220px",
slidesToShow: 1,
speed: 500,
responsive: [
{
breakpoint: 1441,
settings: {
centerPadding: `${width}px`,
}
},
}
]
};
And finally in my return
<Row style={{ margin: '150px 0px'}}>
<Slider {...settings}>
<img alt="" src={destination.photo.url}
onLoad={this.handleImageLoaded} />
<img alt="" src={destination.photo.url}
onLoad={this.handleImageLoaded} />
<img alt="" src={destination.photo.url}
onLoad={this.handleImageLoaded} />
<img alt="" src={destination.photo.url}
onLoad={this.handleImageLoaded} />
</Slider>
</Row>
But I have this error coming up:
I have made the calculations in my console and everything is working so not sure where this is coming from