title: React antd carousel methods
body: <p>I am looking at using the <code>antd</code> Carousel, but I've not seen an example that describes how to use <code>goTo(slideNumber, dontAnimate)</code> method. </p>
  
  <p>I have tried to use answers on this question <a href="https://stackoverflow.com/questions/44114224/react-js-antd-carousel-with-arrows">react.js antd carousel with arrows</a> to make <code>goTo</code> method works for me, but it didn't help, I always get carousel ref as <code>null</code></p>
  
  <pre><code>import * as React from 'react';
  import { createPortal } from 'react-dom';
  import { Modal, Carousel } from 'antd'
  
  export default class ImagePreviewCarousel extends React.Component&lt;any, any&gt; {
  
      carousel = React.createRef();
  
      componentDidMount() {
          console.log(this.carousel);
      }
  
      render() {
          const { url, imgList } = this.props;
          const orderLayout = document.getElementById('order-layout');
          const applicationLayout = document.getElementById('application');
  
          return (
              createPortal(&lt;ImageViewer url={url} onClose={this.props.onClose} imgList={imgList} /&gt;, orderLayout || applicationLayout)
          )
      }
  }
  
  const ImageViewer = (props: IProps) =&gt; {
      return (
          &lt;Modal 
              footer={null} 
              visible={props.onClose} 
              onCancel={props.onClose}
              bodyStyle={{ backgroundColor: '#000' }}
              width={'800px'}
          &gt;
              &lt;div style={{
                  display: 'flex', 
                  flexDirection: 'column', 
                  justifyContent: 'center', 
                  marginTop: 'auto', 
                  marginBottom: 'auto', 
                  width: '100%',
                  height: '100%', 
                  zIndex: 10
              }}&gt;
                  &lt;Carousel ref={node =&gt; (this.carousel = node)}&gt;
                      {props.imgList}
                  &lt;/Carousel&gt;
              &lt;/div&gt;
          &lt;/Modal&gt;
      );
  }
  </code></pre>
  
  <p>result of <code>console.log(this.carousel)</code> always returns <code>null</code>, what am i doing wrong?</p>
  
  <p>p.s react version 16.4.1, </p>