Closed omerbrandis closed 1 year ago
Hi! I made it work installing the types
npm install @types/react-slick
and then using it like this:
import Slider, { CustomArrowProps } from 'react-slick';
...
const PrevArrow = (props: CustomArrowProps) => {
...
If you look at the interface CustomArrowProps
, you will find something like this:
export interface CustomArrowProps {
className?: string | undefined;
style?: React.CSSProperties | undefined;
onClick?: React.MouseEventHandler<any> | undefined;
currentSlide?: number | undefined;
slideCount?: number | undefined;
}
Hope it helps!
Thanks Monica. Can you please tell me how to find this by myself next time ?
Omer.
Well... When I found the same issue about types on a third-party package I asked Chat-GPT, haha. It told me to install the @types
package. Since then, when I don't know the types of the props i research for the @types
Package. Some times the packages already have the types on the main pakage, but it depends of the author.
When I already have the types installed, I only write the name that I guess they used to describe the types. In this case I wrote ArrowProps
and Visual Studio found the CustomArrowProps
for me.
I hope I've explained myself well. If not, let me know ;)
Hello,
I'm trying to use this wonderful library with typescript. encountered the following errors on build :
I worked around it by explicitly writing props:Any. should i have instead written interface MyInt { className style onClick } SamplePrevArrow(props:MyInt) ? ( but that raises the question of which types must i have used for each variable ?)
if possible, I would also greatly appreciate some tutoring regarding how i could figure this out for my self. ( teach a man to fish and all that) :-)