From 66c77ad008456a794547989afffd5fb1b2244d3c Mon Sep 17 00:00:00 2001 From: JonatanSalas Date: Tue, 27 Oct 2020 18:23:39 -0300 Subject: [PATCH] fix(initial): add firstItem prop to carousel, remove dirty-workaround --- src/components/StoryDetail/index.tsx | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/components/StoryDetail/index.tsx b/src/components/StoryDetail/index.tsx index 74670da..29f0812 100644 --- a/src/components/StoryDetail/index.tsx +++ b/src/components/StoryDetail/index.tsx @@ -1,6 +1,6 @@ import { Dimensions, Platform } from 'react-native'; import { Overlay } from 'react-native-elements'; -import React, { useEffect, useRef } from 'react'; +import React, { useRef } from 'react'; import Carousel from 'react-native-snap-carousel'; import { @@ -80,23 +80,6 @@ export const StoryDetail: React.FC = ({ }) => { const carouselRef: any = useRef(null); - useEffect(() => { - let timeoutId: any = null; - - if (initial !== null) { - timeoutId = setTimeout( - () => carouselRef.current.snapToItem(initial, true, true), - Platform.OS === 'ios' ? 25 : 0 - ); - } - - return () => { - if (timeoutId !== null) { - clearTimeout(timeoutId); - } - }; - }, [initial]); - return ( = ({ ref={carouselRef} itemWidth={width} sliderWidth={width} + firstItem={initial} initialScrollIndex={initial} scrollInterpolator={instaEffect.scrollInterpolator} slideInterpolatedStyle={instaEffect.animatedStyles}