I am trying to build a basic Image carousel in SPFx using the PnP Carousel control. Documentation here.
I have added the code based on the documentation including the imports and dependancies to set up the carousel but no images appear when I run using gulp serve. I comment out contentContainerStyles because I am not sure exactly how I want the images styled yet.
export default class PnpTest2 extends React.Component<IPnpTest2Props, {}> {
public render(): React.ReactElement<IPnpTest2Props> {
return (
<div className={ styles.pnpTest2 }>
<div className={ styles.container }>
<div className={ styles.row }>
<div className={ styles.column }>
<span className={ styles.title }>Carousel Test</span>
<Carousel
buttonsLocation={CarouselButtonsLocation.center}
buttonsDisplay={CarouselButtonsDisplay.buttonsOnly}
contentContainerStyles={styles.carouselImageContent}
isInfinite={true}
indicatorShape={CarouselIndicatorShape.circle}
pauseOnHover={true}
element={[
{
imageSrc: 'https://images.unsplash.com/photo-1588614959060-4d144f28b207?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=3078&q=80',
title: 'Colosseum',
description: 'This is Colosseum',
url: 'https://en.wikipedia.org/wiki/Colosseum',
showDetailsOnHover: true,
imageFit: ImageFit.cover
},
{
imageSrc: 'https://images.unsplash.com/photo-1588614959060-4d144f28b207?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=3078&q=80',
title: 'Colosseum',
description: 'This is Colosseum',
url: 'https://en.wikipedia.org/wiki/Colosseum',
showDetailsOnHover: true,
imageFit: ImageFit.cover
},
{
imageSrc: 'https://images.unsplash.com/photo-1588614959060-4d144f28b207?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=3078&q=80',
title: 'Colosseum',
description: 'This is Colosseum',
url: 'https://en.wikipedia.org/wiki/Colosseum',
showDetailsOnHover: true,
imageFit: ImageFit.cover
}
]}
onMoveNextClicked={(index: number) => { console.log(`Next button clicked: ${index}`); }}
onMovePrevClicked={(index: number) => { console.log(`Prev button clicked: ${index}`); }}
/>
</div>
</div>
</div>
</div>
);
}}
I think I am missing a piece of code somewhere but I am not sure where. Below is my render() function located in my .tsx file, I believe everything in it should work but I am not sure if anything else needs to be changed elsewhere. Any help would be appreciated.