rcaferati / react-awesome-slider

React content transition slider. Awesome Slider is a 60fps, light weight, performant component that renders an animated set of production ready UI general purpose sliders with fullpage transition support for NextJS and GatsbyJS. 🖥️ 📱
https://fullpage.caferati.me
MIT License
2.94k stars 296 forks source link

Cannot add an array of child elements #131

Open daltonfury42 opened 4 years ago

daltonfury42 commented 4 years ago

I wanted to add an array of child elements, like this:

import React from 'react';
import AwesomeSlider from 'react-awesome-slider';
import 'react-awesome-slider/dist/styles.css';
import styles from '../../../styles/slider.module.scss';

const Slide = (props) => {
  console.log('This is something tiny missing somehwere...');
  return <div>
    <img src={props.slide.imgSrc} alt={props.slide.imgAlt} />
    <h4>{props.slide.title}</h4>
    <p>{props.slide.subtitle}</p>
  </div>
};

const Slider = (props) => {
  const slides = props.slides.map((slide) => <Slide key={slide.imgSrc} slide={slide} />);
  console.log(slides);
  return (<AwesomeSlider className={styles['aws-btn']}>{slides}</AwesomeSlider>);
};

export default Slider;

Four slides are recognised, but they are coming as empty:

What could be causing this behaviour? Trying to debug, if I put it in a <div>, it gets rendered, nut not in the way it should be, of course:

return (<AwesomeSlider className={styles['aws-btn']}><div>{slides}</div></AwesomeSlider>);