Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

toggle - How to implement custom toggleSwitch in React Native?

I am implementing custom toggleSwitch in react native.I am new in react native. I gone through below link but I am not able achieve the implement.

https://www.digitalocean.com/community/tutorials/how-to-build-a-custom-toggle-switch-with-react

I also check https://dev.to/narendersaini32/how-to-create-custom-toggle-button-in-react-387m

Login.js

 import React from 'react';
import styles from './style';
import {
  SafeAreaView,
  View,
  Switch
} from "react-native";
class Login extends React.Component {
 

  render() {
    return (
      <SafeAreaView>
        <View style={styles.container}>
         </View>

          <View>
               <ToggleComponent/> //I want to import here toggleSwitch
          </View>
         
        </View>
      </SafeAreaView>
    )
  }
}  

export default Login;

ToggleButton.js

import React from 'react';
const ToggleComponent = ({}) => (
 *****************??**************

);



const styles = StyleSheet.create({
  


})

export default ToggleComponent;

I want to implement custom ToggleSwitch.

question from:https://stackoverflow.com/questions/65932349/how-to-implement-custom-toggleswitch-in-react-native

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

import this component in your file where you want to use it.

import ToggleComponent from "../location_of_ToggleComponent.js"

and then you can use it like any other component.

<ToggleComponent /> 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...