You must wrap both your elements in some container. This container is treated as a "whole", no matter what is inside it. In this example below I am using an empty Fragment container
Also, notice that only the piece of code written directly after the &&
is executed if the first part, before the &&
was resolved as true
. (Read more about &&
).
This is why you must wrap everything which should be conditionally-rendered in a container, because if you didn't, only the first element would have been conditionally rendered and anything after it would always get rendered
{ this.state.images > 1 && <>
<LeftArrow goToPrevSlide={this.goToPrevSlide} />
<RightArrow goToNextSlide={this.goToNextSlide} />
</>
}