3DJakob / react-tinder-card

A npm react module for making react elements swipeable like in the dating app tinder.
https://www.npmjs.com/package/react-tinder-card
MIT License
359 stars 110 forks source link

Index.d.ts doesn't allow for useRef #162

Open danielvandenberg95 opened 11 months ago

danielvandenberg95 commented 11 months ago

I copied the code into my project instead, and VSCode is suggesting the following type:

React.ForwardRefExoticComponent<{
    flickOnSwipe?: boolean | undefined;
    children?: any;
    onSwipe?: any;
    onCardLeftScreen?: ((dir: string) => void) | undefined;
    className?: any;
    preventSwipe?: any;
    swipeRequirementType?: any;
    swipeThreshold?: any;
    onSwipeRequirementFulfilled?: any;
    onSwipeRequirementUnfulfilled?: any;
} & React.RefAttributes<...>>

That type could be tighter, but React.FC doesn't accept the ref prop. See also https://stackoverflow.com/questions/60554808/react-useref-with-typescript-and-functional-component.