I'm new to nuka-carousel react.I'm trying to add prev-next arrow button instead of just 'prev' and 'next' written button. I've found various solutions where a decorator function is written.I have tried it but havn't found my desired output. Here is my code:
import Carousel from 'nuka-carousel';
import createReactClass from 'create-react-class';
var Decorators = [
{
component: createReactClass({
render() {
return (
<div>
<i className="fa fa-arrow-left" onClick={this.props.previousSlide} aria-hidden="true"></i>
</div>
)
}
}),
position: 'CenterLeft',
style: {
padding: 20
}
},
{
component: createReactClass({
render() {
return (
<div>
<i className="fa fa-arrow-right" onClick={this.props.nextSlide} aria-hidden="true"></i>
</div>
)
}
}),
position: 'CenterRight',
style: {
padding: 20
}
}
];
return(
<Carousel decortators={Decorators} slidesToShow={3} cellSpacing={50} >
{cards}
</Carousel>
);
I believe you need to set render*Controls
prop of your Carousel
component (where * is specific place of control, such as CenterLeft
or CenterRight
):
<Carousel
renderCenterLeftControls={({ previousSlide }) => (
<button onClick={previousSlide}>
<i className="fa fa-arrow-left" />
</button>
)}
renderCenterRightControls={({ nextSlide }) => (
<button onClick={nextSlide}>
<i className="fa fa-arrow-right"/>
</button>
)}
>
{cards}
</Carousel>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With