toggle buttons react native code example

Example 1: react native toggle button with text

import React, { Component } from 'react'
import { View, Text, Button } from 'react-native'

export default class App extends Component {
  state = {
    textValue: 'Change me'
  }

  onPress = () => {
    this.setState({
      textValue: 'THE NEW TEXT GOES HERE'
    })
  }

  render() {
    return (
      <View style={{paddingTop: 25}}>
        <Text>{this.state.textValue}</Text>
        <Button title="Change Text" onPress={this.onPress} />
      </View>
    )
  }
}

Example 2: react native toggle button with text

import { Switch } from 'react-native-switch';

<Switch
	value={true}  
	onValueChange={(val) => console.log(val)}
	disabled={false}
	activeText={'On'}
	inActiveText={'Off'}
	backgroundActive={'green'}
	backgroundInactive={'gray'}
	circleActiveColor={'#30a566'}
	circleInActiveColor={'#000000'}
/>