title: React Native multiple switches
body: <p>On React-Native, I'm trying to create a screen with multiple switch components, with the possibility of selecting only one at once. When the component loads, only the first switch in on. if you click on it, it turns to off, but if you turn on another one, all the others turn to off.</p>
  
  <p>I'm not sure I have the right approach here, as I'm confused about how to use the component state to do this.</p>
  
  <p>In JS, I would do something like a function that turns all switch to off, but turn on the clicked one, but I don't understand how to this with state.</p>
  
  <p>thanks in advance </p>
  
  <pre><code>import React from 'react'
  import { ScrollView, Text, View, Switch } from 'react-native'
  
  class switchScreen extends React.Component {
    constructor (props) {
      super(props)
      this.state = {
        trueSwitchIsOn: true,
        falseSwitchIsOn: false
      }
    }
  
    switch = (value) =&gt; {
      this.setState({ falseSwitchIsOn: value, trueSwitchIsOn: !value })
    }
  
    render () {
      return (
        &lt;View&gt;
          &lt;Switch
            onValueChange={this.switch}
            value={this.state.trueSwitchIsOn}
          /&gt;
          &lt;Switch
            onValueChange={this.switch}
            value={this.state.falseSwitchIsOn}
          /&gt;
          &lt;Switch
            onValueChange={this.switch}
            value={this.state.falseSwitchIsOn}
          /&gt;
        &lt;/View&gt;
      )
    }
  }
  </code></pre>