Después de que el botón de cambio es verdadero, vuelve a ser falso cuando cierro la página. Cuando sea verdad, quiero que siga siendo así. ¿Como puedo resolver esto? También configuro los colores en otras páginas con isEnabled. Pero como vuelve a ser falso, vuelve al modo claro.
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> )}