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

Typescript - React Native: There is way to save switch button state?

$
0
0

There is way to save switch button state with asyncstorage ?My goal is that when the user clicks on the switcher, then its state will be preserved even when the user exits the application and returns back.

import { View, Text, Switch } from 'react-native';import React from 'react';import styles from './ViewFieldStyles';type Props = {  title: string;  value: boolean;  setValue: () => void;};const ViewField = ({ title, value, setValue }: Props) => {  return (<View style={styles.optionView}><View style={styles.sameRowTextView}><Text style={styles.optionText}>{title}</Text><View style={styles.switchView}><Switch            trackColor={{ false: '#767577', true: 'rgba(4, 76, 163, 0.38)' }}            thumbColor={value ? '#1d16db' : '#f4f3f4'}            ios_backgroundColor='#3e3e3e'            onValueChange={setValue}            value={value}          /></View></View></View>  );};export default ViewField;

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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