I'm having trouble getting these React-Slick slider components to be the same height. They're both responsive divs and resize accordingly as the page size changes, but I would ideally want the div on the left to be the same height as the div on the right.
I have my SimpleSlider defined with the below code snippet.
class SimpleSlider extends React.Component {
constructor(props) {
super(props);
...
}
render() {
let settings = {
dots: true,
infinite: true,
arrows: true,
speed: 500,
slidesToShow: 2,
slidesToScroll: 2,
initialSlide: 0,
responsive: [...]
};
let Components = this.sliderObjects.components;
return (
<div>
<h2> {this.sliderObjects.title} </h2>
<Slider {...settings} >
{
Components.map((component,index)=>
<div key={index} >
<SliderComponent key={index} {...component} />
</div>
)
}
</Slider>
</div>
);
}
}
And then my SliderComponent is defined as so
class SliderComponent extends React.Component{
render() {
return (
<div className='slick-slider-component'>
<h3>{this.props.header}</h3>
<p>{this.props.text}</p>
</div>
);
}
}
Can anyone help me with this? It feels like it should be possible and not overwhelmingly difficult, but I can't figure it out.
If you know your maximum height, you can style your SliderComponent with some minHeight (or min-height in css). You can find some input here.
if you don't know it: hook in your componentWillMount:
componentDidMount() {
const height = document.getElementById('slidercomponent-id').clientHeight;
this.setState({ height });
},
and set this height as your height in your div.