I'm using react-slick-slider and what I want to achieve is to make custom arrows.
So code looks like this:
const FeedbackSlider = () => {
const [isLargeScreen] = useMediaQuery("(min-width: 1050px)")
const sliderRef = useRef<Slider>()
const prev = () => {
sliderRef.current?.slickPrev()
}
const next = () => {
sliderRef.current?.slickNext()
}
const settings = {
dots: false,
infinite: true,
speed: 500,
slidesToShow: (isLargeScreen ? 2 : 1),
slidesToScroll: 1,
prevArrow: (isLargeScreen && <PrevArrow />),
nextArrow: (isLargeScreen && <NextArrow />)
};
return (
<Box px={['2', '4', '8', '16']} mx='auto' pt='12'>
<Slider ref={sliderRef} {...settings}>
// slider cards...
</Slider>
{!isLargeScreen && (
<Flex alignItems='center' w='5xs' justifyContent='space-between' mx='auto' my='5'>
<PrevArrow onClick={prev} />
<NextArrow onClick={next} />
</Flex>)}
</Box >)
The Slider used as type is Slider components imported from react-slick which ref I'm taking I'm getting an error only in VScode code works in browser okay:
No overload matches this call. Overload 1 of 2, '(props: Settings | Readonly): Slider', gave the following error. Type 'MutableRefObject<Slider | undefined>' is not assignable to type 'LegacyRef | undefined'. Type 'MutableRefObject<Slider | undefined>' is not assignable to type 'RefObject'. Types of property 'current' are incompatible. Type 'Slider | undefined' is not assignable to type 'Slider | null'. Type 'undefined' is not assignable to type 'Slider | null'. Overload 2 of 2, '(props: Settings, context: any): Slider', gave the following error. Type 'MutableRefObject<Slider | undefined>' is not assignable to type 'LegacyRef | undefined'.
EDIT:
No overload matches this call. Overload 1 of 2, '(props: Settings | Readonly): Slider', gave the following error. Type '{ children: Element[]; dots: boolean; infinite: boolean; speed: number; slidesToShow: number; slidesToScroll: number; prevArrow: false | Element; nextArrow: false | Element; ref: MutableRefObject<...>; }' is not assignable to type 'Readonly'. Types of property 'nextArrow' are incompatible. Type 'false | Element' is not assignable to type 'Element | undefined'. Type 'false' is not assignable to type 'Element | undefined'. Overload 2 of 2, '(props: Settings, context: any): Slider', gave the following error. Type '{ children: Element[]; dots: boolean; infinite: boolean; speed: number; slidesToShow: number; slidesToScroll: number; prevArrow: false | Element; nextArrow: false | Element; ref: MutableRefObject<...>; }' is not assignable to type 'Readonly'. Types of property 'nextArrow' are incompatible. Type 'false | Element' is not assignable to type 'Element | undefined'.