Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, {Component} from 'react';
- import {Text, View,TextInput,Button,Alert,Switch} from 'react-
- native';
- import TimerMixin from 'react-timer-mixin';
- export default class home extends React.Component {
- constructor(props) {
- super(props)
- this.state = {switchstate:false,timer:null};
- var timer = setInterval(this.tick, 1000);
- this.setState({timer});
- }
- tick=async()=>{
- return await console.log('asdas','iam printing')
- }
- toogleswitchstate=()=>{
- if(this.state.switchstate==false){
- this.setState({switchstate:true})
- }else if(this.state.switchstate==true){
- this.setState({switchstate:false})
- clearInterval(this.timer);
- //geolocation.stopObserving();
- }
- console.log(this.state.switchstate)
- }
- render() {
- return (
- <View style={{flex:1,flexDirection:'column',justifyContent:'space-evenly',alignItems:'center',backgroundColor:datum.secondaryColor}}>
- <Button
- title={String(this.state.switchstate)}
- onPress={()=>this.toogleswitchstate()}
- />
- </View>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement