This repository was archived by the owner on Jun 15, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathClock.js
More file actions
65 lines (58 loc) · 1.2 KB
/
Copy pathClock.js
File metadata and controls
65 lines (58 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React, {Component, useState, useEffect} from 'react';
import {
render,
Text,
View,
Tools,
Dimensions,
StyleSheet,
registerComponent,
} from '../../react-ape/entry';
const {width, height} = Dimensions.get('screen');
const styles = StyleSheet.create({
container: {
position: 'absolute',
left: 70,
top: 20,
backgroundColor: '#331A00',
height: 70,
borderRadius: 30,
width: 110,
},
time: {
color: 'white',
fontSize: 28,
},
});
class Clock extends React.Component {
constructor() {
super();
this.state = {
time: new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1'),
};
}
componentDidMount() {
setInterval(() => {
const time = new Date()
.toTimeString()
.replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1');
this.setState({time});
}, 300);
}
render() {
return (
<View style={styles.container}>
<Text style={styles.time}>
{this.state.time}
</Text>
{/*<Text style={styles.time}>
{this.state.time}
</Text>
<Text style={styles.time}>
{this.state.time}
</Text>*/}
</View>
);
}
}
export default Clock;