-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
147 lines (140 loc) Β· 4.01 KB
/
App.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import React from "react";
import { Button, View, Text, StyleSheet } from "react-native";
import bridgeChecker from "./helpers/bridgeChecker";
import HeavyLoadContainer from "./src/heavyLoad";
import ScrollFunContainer from "./src/animations/ScrollFun";
import StateContainer from "./src/stateManagement/screens/componentState/ComponentStateContainer";
import JsSingletonContainer from "./src/stateManagement/screens/jsSingleton/JsSingletonContainer";
import ContextApiContainer from "./src/stateManagement/screens/contextAPI/ContextApiContainer";
const SCREEN_ID = {
HEAVY_LOAD: "HEAVY_LOAD",
SCROLL_FUN: "SCROLL_FUN",
COMPONENT_STATE: "COMPONENT_STATE",
JS_SINGLETON: "JS_SINGLETON",
CONTEXT: "CONTEXT",
REDUX: "REDUX"
};
export default class App extends React.Component {
state = {
activeScreen: null
};
componentWillMount() {
// bridgeChecker.inspectExistingNativeModules();
// bridgeChecker.inspect({ nativeModule: "UIManager", bundleSize: 1 });
bridgeChecker.inspectTotalTraffic({
nativeModule: "UIManager",
bundleSize: 100
});
}
reset = () => {
bridgeChecker.reset();
};
renderActiveScreen = () => {
console.log(this.state.activeScreen);
console.log(SCREEN_ID.HEAVY_LOAD);
switch (this.state.activeScreen) {
case SCREEN_ID.HEAVY_LOAD:
return <HeavyLoadContainer onReset={this.reset} />;
case SCREEN_ID.SCROLL_FUN:
return <ScrollFunContainer />;
case SCREEN_ID.COMPONENT_STATE:
return <StateContainer />;
case SCREEN_ID.JS_SINGLETON:
return <JsSingletonContainer />;
case SCREEN_ID.CONTEXT:
return <ContextApiContainer />;
default:
return <Text>Not implemented yet</Text>;
}
};
render() {
return (
<View style={styles.container}>
{!this.state.activeScreen && [
<View key={1}>
<Text style={styles.title}>RN Under the hood</Text>
<Button
title={"Heavy Load Demo"}
onPress={() =>
this.setState({ activeScreen: SCREEN_ID.HEAVY_LOAD })
}
/>
<Button
title={"Scroll Animation Demo"}
onPress={() =>
this.setState({ activeScreen: SCREEN_ID.SCROLL_FUN })
}
/>
</View>,
<View key={2}>
<Text style={styles.title}>State Management</Text>
<Button
title={"Component State"}
onPress={() =>
this.setState({ activeScreen: SCREEN_ID.COMPONENT_STATE })
}
/>
<Button
title={"JS Singleton"}
onPress={() =>
this.setState({ activeScreen: SCREEN_ID.JS_SINGLETON })
}
/>
<Button
title={"React Context API"}
onPress={() => this.setState({ activeScreen: SCREEN_ID.CONTEXT })}
/>
<Button
title={"Redux"}
onPress={() => this.setState({ activeScreen: SCREEN_ID.REDUX })}
/>
</View>
]}
{this.state.activeScreen && this.renderActiveScreen()}
<View style={styles.header}>
{this.state.activeScreen && (
<Button
title="Back"
onPress={() => this.setState({ activeScreen: null })}
/>
)}
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 30,
backgroundColor: "white",
alignItems: "center",
justifyContent: "space-around"
},
header: {
position: "absolute",
bottom: 10,
left: 0
},
row: {
flexDirection: "row"
},
title: {
fontSize: 20,
alignSelf: "center"
},
switchContainer: {
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
padding: 10,
marginBottom: 10,
backgroundColor: "green",
borderRadius: 6
},
switchLabel: {
fontSize: 16,
marginRight: 10,
color: "black"
}
});