Hide/Show components in react native

后端 未结 24 2008
囚心锁ツ
囚心锁ツ 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:17

    The following example is coding in typescript with Hooks.

    import React, { useState, useEffect } from "react";
    
    ........
    
    const App = () => {
    
       const [showScrollView, setShowScrollView] = useState(false);
    
       ......
    
       const onPress = () => {
        // toggle true or false
        setShowScrollView(!showScrollView);
      }
    
      ......
    
          
            {showScrollView ? () : null}
          
      ......
    
    }
    

提交回复
热议问题