dohooo / react-native-reanimated-carousel

🎠 React Native swiper/carousel component, fully implemented using reanimated v2, support to iOS/Android/Web. (Swiper/Carousel)
https://react-native-reanimated-carousel.vercel.app
MIT License
2.75k stars 317 forks source link

ViewPropTypes will be removed from React Native, along with all other PropTypes. We recommend that you migrate away from PropTypes and switch to a type system like TypeScript. If you need to continue using ViewPropTypes, migrate to the 'deprecated-react-native-prop-types' package. #612

Open Mynini opened 4 months ago

Mynini commented 4 months ago

while do not resolution this problem?

ViewPropTypes will be removed from React Native, along with all other PropTypes. We recommend that you migrate away from PropTypes and switch to a type system like TypeScript. If you need to continue using ViewPropTypes, migrate to the 'deprecated-react-native-prop-types' package.

platrom: react-native:0.73

dosubot[bot] commented 4 months ago

To resolve the deprecation warning for ViewPropTypes in React Native 0.73, you have two main options: migrating to TypeScript or using the deprecated-react-native-prop-types package. Here are the steps for both approaches:

Using deprecated-react-native-prop-types Package

  1. Install the package:

    npm install deprecated-react-native-prop-types
  2. Update your imports: Replace any import of ViewPropTypes from react-native with deprecated-react-native-prop-types.

    import { ViewPropTypes } from 'deprecated-react-native-prop-types';

Migrating to TypeScript

If you decide to migrate to TypeScript, you can define the types directly without relying on ViewPropTypes.

  1. Install TypeScript and necessary types:

    npm install typescript @types/react @types/react-native
  2. Create a tsconfig.json file:

    {
     "compilerOptions": {
       "target": "es5",
       "module": "commonjs",
       "strict": true,
       "jsx": "react",
       "esModuleInterop": true,
       "skipLibCheck": true,
       "forceConsistentCasingInFileNames": true
     }
    }
  3. Update your component to use TypeScript types: Replace ViewPropTypes with ViewStyle from react-native.

    import { StyleProp, ViewStyle } from 'react-native';
    
    interface MyComponentProps {
     style?: StyleProp<ViewStyle>;
    }
    
    const MyComponent: React.FC<MyComponentProps> = ({ style }) => {
     return <View style={style} />;
    };

By following either of these methods, you can resolve the deprecation warning for ViewPropTypes in React Native 0.73.

#### Details **Sources** - [src/types.ts](https://github.com/dohooo/react-native-reanimated-carousel/blob/main/src/types.ts) - [src/components/ScrollViewGesture.tsx](https://github.com/dohooo/react-native-reanimated-carousel/blob/main/src/components/ScrollViewGesture.tsx) - [src/components/rnr-demo.test.tsx](https://github.com/dohooo/react-native-reanimated-carousel/blob/main/src/components/rnr-demo.test.tsx) - [example/app/tsconfig.json](https://github.com/dohooo/react-native-reanimated-carousel/blob/main/example/app/tsconfig.json) - [example/expo/tsconfig.json](https://github.com/dohooo/react-native-reanimated-carousel/blob/main/example/expo/tsconfig.json) - [example/app/src/pages/complex/index.tsx](https://github.com/dohooo/react-native-reanimated-carousel/blob/main/example/app/src/pages/complex/index.tsx) - [tsconfig.json](https://github.com/dohooo/react-native-reanimated-carousel/blob/main/tsconfig.json)
**About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Mynini commented 4 months ago

To resolve the deprecation warning for ViewPropTypes in React Native 0.73, you have two main options: migrating to TypeScript or using the deprecated-react-native-prop-types package. Here are the steps for both approaches:

Using deprecated-react-native-prop-types Package

  1. Install the package:
    npm install deprecated-react-native-prop-types
  2. Update your imports: Replace any import of ViewPropTypes from react-native with deprecated-react-native-prop-types.
    import { ViewPropTypes } from 'deprecated-react-native-prop-types';

Migrating to TypeScript

If you decide to migrate to TypeScript, you can define the types directly without relying on ViewPropTypes.

  1. Install TypeScript and necessary types:
    npm install typescript @types/react @types/react-native
  2. Create a tsconfig.json file:
    {
     "compilerOptions": {
       "target": "es5",
       "module": "commonjs",
       "strict": true,
       "jsx": "react",
       "esModuleInterop": true,
       "skipLibCheck": true,
       "forceConsistentCasingInFileNames": true
     }
    }
  3. Update your component to use TypeScript types: Replace ViewPropTypes with ViewStyle from react-native.

    import { StyleProp, ViewStyle } from 'react-native';
    
    interface MyComponentProps {
     style?: StyleProp<ViewStyle>;
    }
    
    const MyComponent: React.FC<MyComponentProps> = ({ style }) => {
     return <View style={style} />;
    };

By following either of these methods, you can resolve the deprecation warning for ViewPropTypes in React Native 0.73.

Details

Sources

About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Mynini commented 4 months ago

is not work for me . why react-native-reanimated-carousel do not instead ViewPropTypes with new method?

dosubot[bot] commented 4 months ago

To resolve the deprecation warning for ViewPropTypes in React Native 0.73, you should replace any usage of ViewPropTypes with ViewStyleProp from the react-native package. Here is an example of how you can implement this change in the TCarouselProps interface:

import type { StyleProp, ViewStyle } from "react-native";
import type { PanGesture } from "react-native-gesture-handler";
import type {
  AnimatedStyleProp,
  SharedValue,
  WithSpringConfig,
  WithTimingConfig,
} from "react-native-reanimated";
import type Animated from "react-native-reanimated";

import type { TParallaxModeProps } from "./layouts/parallax";
import type { TStackModeProps } from "./layouts/stack";

export type TCarouselProps<T = any> = {
  ref?: React.Ref<ICarouselInstance>
  defaultScrollOffsetValue?: SharedValue<number>
  loop?: boolean
  data: T[]
  autoFillData?: boolean
  defaultIndex?: number
  autoPlay?: boolean
  autoPlayReverse?: boolean
  autoPlayInterval?: number
  scrollAnimationDuration?: number
  style?: StyleProp<ViewStyle>
  onConfigurePanGesture?: (panGesture: PanGesture) => void
  windowSize?: number
  pagingEnabled?: boolean
  snapEnabled?: boolean
  overscrollEnabled?: boolean
  enabled?: boolean
  withAnimation?: WithAnimation
  testID?: string
  maxScrollDistancePerSwipe?: number
  minScrollDistancePerSwipe?: number
  fixedDirection?: "positive" | "negative"
  customConfig?: () => CustomConfig
  customAnimation?: (value: number) => AnimatedStyleProp<ViewStyle>
  renderItem: CarouselRenderItem<T>
  onSnapToItem?: (index: number) => void
  onScrollStart?: () => void
  onScrollEnd?: (index: number) => void
  onProgressChange?: ((
    offsetProgress: number,
    absoluteProgress: number
  ) => void) | SharedValue<number>
}

This change ensures compatibility with React Native 0.73 and removes the deprecated ViewPropTypes [1].

#### Details **About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Mynini commented 4 months ago

not work.

image
BrodaNoel commented 4 months ago

This is all fixed in version 4.0.0 -alphax