React Native 时间显示组件

//没找着时间显示的组件,自己弄一个吧

import * as React from 'react';
import { Text,StyleSheet } from 'react-native';
//import { Constants } from 'expo';

// You can import from local files
//import AssetExample from './components/AssetExample';

// or any pure javascript modules available in npm
//import { Card } from 'react-native-paper';


export default class TimeRecorder extends React.Component {
  constructor(props) {
    super(props);
    this.state = { isShowingText:  " " };

    setInterval(() => {
      this.setState(previousState => {  
        return { isShowingText: new Date().toLocaleTimeString() };
      });
    }, 1000);
  }

  render() {
    return (
      {this.state.isShowingText}
    );
  }
}
 

const styles = StyleSheet.create({  
  paragraph: {
    margin: 24,
    fontSize: 12,
    fontWeight: 'bold',
    textAlign: 'center',
  },
});
精彩稍后继续,尽请点赞打赏.

你可能感兴趣的:(React Native 时间显示组件)