Download react-slick/examples/PreviousNextMethods.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-slick/examples/PreviousNextMethods.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-slick/examples/PreviousNextMethods.js
-
curl -L -o PreviousNextMethods.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-slick/examples/PreviousNextMethods.js
1.19 kB
| import React, { useRef } from "react"; | |
| import Slider from "react-slick"; | |
| function PreviousNextMethods() { | |
| let sliderRef = useRef(null); | |
| const next = () => { | |
| sliderRef.slickNext(); | |
| }; | |
| const previous = () => { | |
| sliderRef.slickPrev(); | |
| }; | |
| const settings = { | |
| dots: true, | |
| infinite: true, | |
| speed: 500, | |
| slidesToShow: 1, | |
| slidesToScroll: 1 | |
| }; | |
| return ( | |
| <div className="slider-container"> | |
| <Slider | |
| ref={slider => { | |
| sliderRef = slider; | |
| }} | |
| {...settings} | |
| > | |
| <div key={1}> | |
| <h3>1</h3> | |
| </div> | |
| <div key={2}> | |
| <h3>2</h3> | |
| </div> | |
| <div key={3}> | |
| <h3>3</h3> | |
| </div> | |
| <div key={4}> | |
| <h3>4</h3> | |
| </div> | |
| <div key={5}> | |
| <h3>5</h3> | |
| </div> | |
| <div key={6}> | |
| <h3>6</h3> | |
| </div> | |
| </Slider> | |
| <div style={{ textAlign: "center" }}> | |
| <button className="button" onClick={previous}> | |
| Previous | |
| </button> | |
| <button className="button" onClick={next}> | |
| Next | |
| </button> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| export default PreviousNextMethods; | |