oliviertassinari / react-swipeable-views

A React component for swipeable views. :snowflake:
https://react-swipeable-views.com/
MIT License
4.46k stars 474 forks source link

SwipeableViewsProps is not allowed spread parameter(3 dot operation) #562

Open PeterJSung opened 4 years ago

PeterJSung commented 4 years ago

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
vanhoutenbos commented 4 years ago

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.

muhammedogz commented 1 year ago

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