Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Disabling a list item with a toggle switch

$
0
0

I am trying to disable the text under a toggle switch which enables a modal. I want the modal to show when the toggle is enabled and disabled when not.The code is below.

const PrivacySecurity = (props: Props) => {    const toggleSwitch = () => setIsEnabled((previousState) => !previousState);    const [isEnabled, setIsEnabled] = useState(true);    const [visible, setVisible] = React.useState(false);    const showModal = () => setVisible(true);    const hideModal = () => setVisible(false);    const [typeSelected, setTypeSelected] = useState();    const buttonState  =  () => {    if (toggleSwitch === setIsEnabled) {        console.log('true')            true        } else {            false            console.log('false')        }    }  

The logs do not show when I toggle the switch.

<List.Item title="Require Biometrics"                         right={() => <Switch style={{top: 15,}} trackColor={{ true: "#53A089"} }                         value={isEnabled} onValueChange={toggleSwitch}/>}                         left={() => <List.Icon icon="tag-outline" />}                    /><List.Item                         title="Biometric Preferences"                         description="Face ID selected"                        right={() => <List.Icon icon="greater-than" />}                         left={() => <List.Icon icon="tag-outline" />}                         onPress= {modalOne }                    />

I thought about declaring the switch as a state but i am doing something stupid I think. Please help.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>