🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-native-switch-button-opensource

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-switch-button-opensource

a react native library for switch button

1.0.0
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

React Native Custom Switch Component

A customizable React Native Switch Component

Installation

Install the package using npm or yarn:

npm i react-native-switch-button-opensource

Usage

import React, { useState } from 'react';
import { View, StyleSheet,Text } from 'react-native';
import Switch from 'react-native-switch-button-opensource';

const App = () => {
  const [isOn, setIsOn] = useState(false);

  const handleToggle = (newState) => {
    setIsOn(newState);
    // Add your additional logic here
  };

  return (
    <View style={styles.container}>
      <Switch isOn={isOn} handleToggle={handleToggle} />
    
      <Text style={styles.label}>{isOn ? 'On' : 'Off'}</Text>

    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    padding: 20,
  },
  label: {
    marginLeft: 10,
    fontSize: 16,
  },
});

export default App;

Props

Required Props

  • isOn: boolean value for on/off state of switch
  • handleToggle: a call back function to change state of switch

License

This project is licensed under the MIT License - see the LICENSE file for details. Feel free to further customize the code according to your project's specifics.

Keywords

react

FAQs

Package last updated on 16 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts