Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
Switch button becomes false again

After the switch button is true, it becomes false again when I close the page. When it's true, I want it to stay that way. How can I solve this? I also set the colors on other pages with isEnabled. But since it is false again, it returns to light mode.

    export const [isEnabled, setIsEnabled] = React.useState(false);
export const toggleSwitch = () => setIsEnabled(previousState => !previousState);


export function SettingsAccount(props) {
const { navigate } = props.navigation;

return(
  
  <SafeAreaView>
  <View style = {styles.container}>
            <TouchableOpacity onPress ={() => {navigationService.navigate('MyAccount', null);} 
          }>
              <Image style= {styles.imageSt} source={require('../../assets/arrow-left-circle.png')} />
            </TouchableOpacity>
            <View style = {styles.textView}>
              <Text style = {styles.textStyle}>Uygulama Ayarları</Text>
            </View>
</View>
<View style={styles.SwitchStyle}>
      <Switch
        trackColor={{ false: "#767577", true: "#81b0ff" }}
        thumbColor={isEnabled ? "#f5dd4b" : "#f4f3f4"}
        ios_backgroundColor="#3e3e3e"
        onValueChange={toggleSwitch}
        value={isEnabled}
        
        
      />
</View>
<View>
  <TouchableOpacity style={{backgroundColor: isEnabled ? "green":"red", marginTop: 50}}>
    <Text>
      Deneme Buton
    </Text>
  </TouchableOpacity>
</View>
</SafeAreaView>
)}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda