react-swipeable-views icon indicating copy to clipboard operation
react-swipeable-views copied to clipboard

SwipeableViewsProps is not allowed spread parameter(3 dot operation)

Open PeterJSung opened this issue 4 years ago • 2 comments

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

hello, i use react-swipeable-views with typescript

and i`ll try to pass object using spread(3dot operation), like below

import SwipeableViews, { SwipeableViewsProps } from 'react-swipeable-views';

const test = React.FC = () => {
    const propsSlide: SwipeableViewsProps  = {
        ...
    }
    return (
        <>
            <SwipeableViews {...propsSlide}>
            <SwipeableViews/>
        </>
    )
}

the problem is SwipeableViews only accept attribute IntrinsicClassAttributes<SwipeableViews>

beside, props object is SwipeableViewsProps in react-swipeable-views.

and in this case, where can i use SwipeableViewsProps object and

how do i pass to object as property with 3 dot operation.?

thank you

Your Environment

Tech Version
@types/react-swipeable-views ^0.13.0
react-swipeable-views ^0.13.3
React ^16.12.0
platform Window
etc

PeterJSung avatar Jan 02 '20 03:01 PeterJSung

Hi,

Well noticed, i will try and test this next week, if you want you can create a PR which addresses this issue i will than check and merge the PR within a day.

vanhoutenbos avatar Jan 15 '20 18:01 vanhoutenbos

any update on this issue?. I had the same issue as well. It is not nice solution but I have a workaround like this.

import SwipeableViews, { SwipeableViewsProps } from 'react-swipeable-views';

type MySwipeableViewsProps = SwipeableViewsProps;

const MySwipeableViews = ({ ...rest }: MySwipeableViewsProps) => {
  return (
    <SwipeableViews
      containerStyle={{
        transition: 'transform 0.35s cubic-bezier(0.15, 0.3, 0.25, 1) 0s',
      }}
      {...(rest as any)}
    />
  );
};

export default MySwipeableViews;

Edit: Since I want to apply initial rendering in every SwipeableViews, I was adding this containerStyle and creating my custom value. Ref: https://github.com/oliviertassinari/react-swipeable-views/issues/599#issuecomment-657601754

muhammedogz avatar Mar 29 '23 13:03 muhammedogz