react.js antd carousel with arrows

后端 未结 7 2058
既然无缘
既然无缘 2021-01-12 11:26

I am looking at using the antd Caroseul, but I\'ve not seen an example that creates a prev/next or pause button.

const { Carousel } = antd;

ReactDOM.render         


        
7条回答
  •  一生所求
    2021-01-12 11:40

    just follow this code : use useRef hook and assign a Ref to Carousel and then call next and prev method by refrence.

    import React, { useRef, Fragment } from "react";
    import { Carousel } from "antd";
    
    const MyCarousel = () => {
    const slider = useRef(null);
    
    return ( 
    
        
        
            
    Item 1
    Item 2
    Item 3
    )}

提交回复
热议问题