-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestCacheView.js
More file actions
48 lines (39 loc) · 1.3 KB
/
testCacheView.js
File metadata and controls
48 lines (39 loc) · 1.3 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
import React, { Component, PureComponent } from "react";
import { Platform, StyleSheet, Text, View, Button } from "react-native";
class Mc extends PureComponent{ //这里改成Component试试?
render(){
console.log("guangy mc render......")
return <Text>{this.props.num}</Text>
}
}
export default class testCacheView extends Component{
constructor(props) {
super(props);
this.state = {
isVisible:true
}
}
_renderContent(){ //切换两种方案试试?
let height = this.state.isVisible ? 100 : 0;
return <View style={{height, backgroundColor:"yellow"}}>
<Mc num={1}/>
<Mc num={2}/>
</View>
// return this.state.isVisible ? <View style={{backgroundColor:"yellow"}}>
// <Mc num={1}/>
// <Mc num={2}/>
// </View> : null;
}
render(){
return <View style={{flex:1, backgroundColor:"red"}}>
<Button title="click" onPress={()=>{
this.setState({isVisible:!this.state.isVisible})
}}/>
<View style={{height:100, backgroundColor:"green"}}/>
{
this._renderContent()
}
<View style={{flex:1, backgroundColor:"blue"}}/>
</View>
}
}