Hide/Show components in react native

后端 未结 24 2007
囚心锁ツ
囚心锁ツ 2020-12-07 08:43

I\'m really new to React Native and I\'m wondering how can I hide/show a component.
Here\'s my test case:



        
24条回答
  •  失恋的感觉
    2020-12-07 09:20

    Actually, in iOS development by react-native when I use display: 'none' or something like below:

    const styles = StyleSheet.create({
      disappearImage: {
        width: 0,
        height: 0
      }
    });
    

    The iOS doesn't load anything else of the Image component like onLoad or etc, so I decided to use something like below:

    const styles = StyleSheet.create({
      disappearImage: {
        width: 1,
        height: 1,
        position: 'absolute',
        top: -9000,
        opacity: 0
      }
    });
    

提交回复
热议问题