Skip to content Skip to sidebar Skip to footer

React Native (ios). How To Update Value Date (millisecond)

I'm a newbie in react-native and never learn javascript I need to update value date(millisecond) but I don't know how to update value in realtime like lat,lon that I got from react

Solution 1:

A simplified answer -

  constructor(props) {
    super(props);
    this.state = {
      time: ''
    };
  }

  componentDidMount() {
    setInterval(() => {
      this.setState({
        time: new Date().getMilliseconds()
      });
    }, 1000);
  }

  render() {
    return (
      <View style={styles.container}>
        <Text>{this.state.time}</Text>
      </View>
    );
  }

Post a Comment for "React Native (ios). How To Update Value Date (millisecond)"