title: How to create simple switch toggle to switch between dark theme and light theme in react native
body: <p>I am creating a simple switch component that is if turned on the theme of the app will be light otherwise it would be dark.</p>
  <p>Here is what i tried but it is not working. How can i make the toggle switch the theme of the whole app?</p>
  <pre><code>import { StatusBar } from 'expo-status-bar';
  import React, {useState} from 'react';
  import { StyleSheet, Text, View, Switch, Appearance } from 'react-native';
  
  export default function App() {
    const [isEnabled, setIsEnabled] = useState(false);
  
    const toggleSwitch = () =&gt; setIsEnabled(previousState =&gt; !previousState);
    const colorScheme = Appearance.getColorScheme();
    if (colorScheme === 'dark') {
      
    }
    return (
      &lt;View style={styles.container}&gt;
        &lt;StatusBar style=&quot;auto&quot; /&gt;
        &lt;Switch
          style={{marginBottom:500, marginLeft:150}}
          trackColor={{ false: &quot;light&quot;, true: &quot;dark&quot; }}
          thumbColor={isEnabled ? colorScheme == 'light' : colorScheme == 'dark'}
          ios_backgroundColor=&quot;#3e3e3e&quot;
          onValueChange={toggleSwitch}
          value={isEnabled}
        /&gt;
      &lt;/View&gt;
    );
  </code></pre>
  <p>}</p>