title: Slick Carousel Slide Count
body: <p>I am using the slick carousel and trying to get the slide count. I am using React.js with ES6, below is the function I'm using to return the count but what I don't understand is that the console.log("inside" + n); prints the value whereas the one outside prints null, what am I doing wrong? </p>
  
  <pre><code> countSlides() {
      let n = 0;
      $(this.innerSelector).on('init', (event, slick) =&gt; {
        n = slick.slideCount;
        console.log("inside" + n);
      });
  
      console.log("outside" + n);
      return n;
  
    }
  </code></pre>
  
  <p>I have created a class for the carousel so I can instantiate in different parent components. e.g for this one I have:</p>
  
  <pre><code>class ImageCarousel extends React.Component {
    constructor() {
      super();
      this.carouselDidStart = false;
      this.carouselControl = new CarouselControl({
        outerSelector: ".carousel-container",
        innerSelector: ".extra-images-container",
        infinite: false
      });
    }
  </code></pre>
  
  <p>And then in the CarouselControl class I am trying to add this countSlides function so I can find the number of slides like this.carouselControl.countSlides();</p>