-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
PreviousNextMethods.js
58 lines (56 loc) · 1.16 KB
/
PreviousNextMethods.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;