react-native-shimmer icon indicating copy to clipboard operation
react-native-shimmer copied to clipboard

Doesn't work for <Text> inside <View>

Open rahuljiresal opened this issue 8 years ago • 12 comments

This works with

<Shimmer>
    <Text>Hello</Text>
</Shimmer>

But for any other kind of views, it does not work. For example, if I have a bunch of texts inside a View, it won't work.

<Shimmer>
    <View>
         <Text>Hello</Text>
         <Text>Hello</Text>
         <Text>Hello</Text>
    </View
</Shimmer>

rahuljiresal avatar Jun 14 '16 03:06 rahuljiresal

Hi, you're right it doesn't work and I'm not sure why. For the time being do something like this instead:

<Shimmer>
  <Text>Hello{'\n'}Hello{'\n'}Hello</Text>
</Shimmer>

oblador avatar Jun 14 '16 09:06 oblador

Haha I wish. I was actually trying to do the following.. and then tested with the earlier example I gave (because it is simpler)..

I realized that a <View/> is something that is not shimmering. It works well with <Image/> but not if it is inside a View.

<Shimmer>
    <View>
        <View key={i} style={{ flex: 1, flexDirection: 'row', marginTop: 8, marginBottom: 8 }}>
            <View style={{ height: 40, width: 40, backgroundColor: color }} />
            <View style={{ flex: 1, flexDirection: 'column', marginLeft: 8 }}>
            <View style={{ flex: 1, height: 16, backgroundColor: color, marginBottom: 4, marginRight: 200 }} / 
            <View style={{ flex: 1, height: 16, backgroundColor: color, marginBottom: 4, marginRight: 80 }} />
        </View>
    </View>
</Shimmer>

rahuljiresal avatar Jun 14 '16 17:06 rahuljiresal

Hmm, that kinda looks like something you could easily solve with an image, no?

oblador avatar Jun 15 '16 12:06 oblador

Yes. I could. That is a very ugly solution though. Especially in my case because I need to have multiple of those views inside Shimmer to support all iPhone and iPad screen sizes and orientations.

rahuljiresal avatar Jun 15 '16 17:06 rahuljiresal

Hi @oblador any plans to work on this?

rturk avatar Sep 11 '16 22:09 rturk

Is this package still maintained? Would love to use the shimmering for a skeleton view. But it'd be quite useless without support for views. Maybe I could allocate some time to look into the issue in the next month. Does it work properly on Android, or is it broken on both iOS and Android?

MrLoh avatar Sep 14 '17 10:09 MrLoh

It is maintained, although this library is merely a wrapper for native libraries from Facebook which as far as I gather has this limitation. I'd be grateful if you spent some time to investigate it further and would merge a fix.

oblador avatar Sep 14 '17 11:09 oblador

Why do you think the Facebook library has that limitation? I haven't used it, but I thought it's what Facebook build for the paper app and is still using for the loading animation in its app today, in those skeletons views it's certainly not Text that's shimmering.

MrLoh avatar Sep 14 '17 11:09 MrLoh

Because it has problems with nested views in general. You can acheive that effect with an image too.

oblador avatar Sep 14 '17 13:09 oblador

Hello @oblador. Thanks for your amazing libraries like react-native-vector-icons and react-native-shimmer. I am currently facing an issue with the shimmer. It just doesn't work with Multiples components inside the Shimmer. In iOS works perfect. I am gonna try to check what caused this problem

AugustoAleGon avatar Oct 24 '17 15:10 AugustoAleGon

@AugustoAleGon did you ever get anywhere with this?

MrLoh avatar Dec 03 '17 00:12 MrLoh

I think if this is a limitation of the native libraries we're binding to we can easily work around it by walking the node tree and wrapping all leaf nodes (children who have no children which are views) in the native component

Otherwise we could ask the native library authors if they could?

bennyhobart avatar Apr 08 '18 23:04 bennyhobart