I added the react-slick
into my project to show a carousel
.
I want to control my slider with custom next and prev button which is in the top of the slider contents. so I followed the custom arrow documentation, but I don't want to show my buttons inside the slick contents, I want to give the controls to the button above the slider contents. How to achieve this?
I Included my code from the component I created.
import React from 'react';
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
import Slider from "react-slick";
import { styled } from '@material-ui/styles';
import Button from '@material-ui/core/Button';
function SampleNextArrow(props) {
const { onClick } = props;
return (
<React.Fragment>
<Button
onClick={onClick} className="slickRight">
Next
</Button>
</React.Fragment>
);
}
function SamplePrevArrow(props) {
const { onClick } = props;
return (
<React.Fragment>
<Button
onClick={onClick} className="slickLeft">
Prev
</Button>
</React.Fragment>
);
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {}
}
render() {
var settings = {
infinite: true,
speed: 500,
slidesToShow: 4,
slidesToScroll: 1,
nextArrow: <SampleNextArrow />,
prevArrow: <SamplePrevArrow />,
};
return (
<div>
{/*Want to Add Control to this Buttons*/
<Button>Prev</Button>
<Button>Next</Button>
<div className="container">
<Slider {...settings}>
<div>
<h3>1</h3>
</div>
<div>
<h3>2</h3>
</div>
<div>
<h3>3</h3>
</div>
</Slider>
</div>
</div>
);
}
}
export default App;