-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jsx.js
64 lines (45 loc) · 1.29 KB
/
Jsx.js
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
/**
* Created by chx on 2017/7/25.
*/
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
TouchableWithoutFeedback,
Image,
FlatList,
} from 'react-native';
export default class Jsx extends Component {
static navigationOptions = ({navigation}) => __Navigator.setNavigationOptions({navigation}, {
title: 'Jsx'
});
constructor(props) {
super(props);
this.state = {
showText: true
};
this.displayContent = 'content'
// 每1000毫秒对showText状态做一次取反操作
setInterval(() => {
// this.setState(previousState => {
// return { showText: !previousState.showText };
// });
this.setState({
showText: !this.state.showText,
})
}, 1000);
}
render() {
// 根据当前showText的值决定是否显示text内容
// let display = this.state.showText ? this.displayContent : ' ';
let display = this.state.showText;
return (
display ? (
<Text style={{marginTop:50, backgroundColor: 'red'}}>123455</Text>
) : (
<Text style={{backgroundColor: 'green'}}>12</Text>
)
);
}
}