mercredi 22 janvier 2020

Is there a way to display the middle radio button turned on when entering the screen?

Is there a way to display the middle radio button turned on when entering to the screen? And even when I press the same radio button it will not turn itself off but I will only be able to switch between them and not turn them off when I push on them.

this is my example :

import React, { useState } from 'react';
import { View, Text, StyleSheet, Platform } from 'react-native';
import { CheckBox } from 'react-native-elements';

    const SettingsScreen = props => {
    const [checked6, setChecked6] = useState(true);
    const [checked7, setChecked7] = useState(null);
    const [checked8, setChecked8] = useState(null);
    const handlePress = title => {
        checked6 === title ? setChecked6(null) : setChecked6(title)
        checked7 === title ? setChecked7(null) : setChecked7(title)
        checked8 === title ? setChecked8(null) : setChecked8(title)
}

          return (
                <CheckBox
                    iconLeft
                    checkedColor='green'
                    title='bomba6'
                    checkedIcon='dot-circle-o'
                    uncheckedIcon='circle-o'
                    checked={checked6 === 'bomba6'}
                    onPress={() => handlePress('bomba6')}
                />
                <CheckBox
                    iconLeft
                    checkedColor='green'
                    title='bomba7'
                    checkedIcon='dot-circle-o'
                    uncheckedIcon='circle-o'
                    checked={checked7 === 'bomba7'}
                    onPress={() => handlePress('bomba7')}
                />
                <CheckBox
                    iconLeft
                    checkedColor='green'
                    title='bomba8'
                    checkedIcon='dot-circle-o'
                    uncheckedIcon='circle-o'
                    checked={checked8 === 'bomba8'}
                    onPress={() => handlePress('bomba8)')}
                />
             );
          };

      export default SettingsScreen;




Aucun commentaire:

Enregistrer un commentaire