oblador / react-native-shimmer

Simple shimmering effect for any view in React Native
MIT License
686 stars 89 forks source link

Shimmer not working on iOS #27

Open Gabogg07 opened 4 years ago

Gabogg07 commented 4 years ago

I am currently working with "react-native": "0.61.3" and "react-native-shimmer": "^0.6.0".

I have a Shimmer with a nested flatlist inside. For android it works like a charm but for iOS it is not working. Sometimes you can see only a flicker once when it renders, then just no animation, change or opacity, nothing.

<Shimmer >
          <FlatList .../> //Deleted it for simplicity purposes 
</Shimmer>
Btace13 commented 4 years ago

Any updates on this?

pragadeeshk commented 3 years ago

Temporary workaround, set "animating" as false initially and change from false to true with a time out on componentDidMount or useEffect callbacks. It works

jindalankush28 commented 3 years ago

@pragadeeshk can you give example code

pragadeeshk commented 3 years ago

@jindalankush28 hope this helps

export default Component = () => {
    const [loading, setLoading] = useState(false)

    useEffect(()=>{
        setTimeout(()=>{
            setLoading(true)
        }, 200)
    }, [])

    return (
        <ShimmerView loading={loading}>
                //View to shimmer
        </ShimmerView>
    )
}
jindalankush28 commented 3 years ago

now it stopped working on android as well 😂

pragadeeshk commented 3 years ago

@jindalankush28 Please share your code snippet.

jindalankush28 commented 3 years ago

const SpecialityContentLoader = () => { const [visible, setVisibile] = useState(false);

useEffect(() => { setTimeout(() => { setVisibile(true); }, 10); }, []); return ( <FlatList numColumns={3} columnWrapperStyle={{ flex: 1, justifyContent: 'flex-start', }} data={[{id: 1}, {id: 2}, {id: 3}]} renderItem={({item}) => { return ( <View key={item.id} style={{ ... }}> <TouchableOpacity onPress={() => null}>

//shimmer component

); }} /> ); }; @pragadeeshk its working on ios but not on android with ur method

pragadeeshk commented 3 years ago

@jindalankush28 Try increasing the timeout from 10 to at least 200. Also I don't see your ShimmerView component in the code. I hope you are setting loading={visible} as property for your ShimmerView