File tree Expand file tree Collapse file tree 1 file changed +23
-21
lines changed Expand file tree Collapse file tree 1 file changed +23
-21
lines changed Original file line number Diff line number Diff line change 1
1
import * as React from "react" ;
2
2
import { Button , StyleSheet , Text , View } from "react-native" ;
3
3
4
+ // styles
5
+ const styles = StyleSheet . create ( {
6
+ root : {
7
+ alignItems : "center" ,
8
+ alignSelf : "center"
9
+ } ,
10
+ buttons : {
11
+ flexDirection : "row"
12
+ } ,
13
+ button : {
14
+ flex : 1 ,
15
+ paddingVertical : 0
16
+ } ,
17
+ greeting : {
18
+ color : "#999" ,
19
+ fontWeight : "bold"
20
+ }
21
+ } ) ;
22
+
4
23
export interface IProps {
5
24
name : string ;
6
25
enthusiasmLevel ?: number ;
@@ -10,26 +29,26 @@ interface IState {
10
29
enthusiasmLevel : number ;
11
30
}
12
31
13
- export default class Hello extends React . Component < IProps , IState > {
32
+ class Hello extends React . Component < IProps , IState > {
14
33
constructor ( props : IProps ) {
15
34
super ( props ) ;
16
-
17
35
if ( ( props . enthusiasmLevel || 0 ) <= 0 ) {
18
36
throw new Error ( "You could be a little more enthusiastic. :D" ) ;
19
37
}
20
-
21
38
this . state = {
22
39
enthusiasmLevel : props . enthusiasmLevel || 1
23
40
} ;
24
41
}
25
42
26
43
public onIncrement = ( ) =>
27
44
this . setState ( { enthusiasmLevel : this . state . enthusiasmLevel + 1 } ) ;
45
+
28
46
public onDecrement = ( ) =>
29
47
this . setState ( {
30
48
enthusiasmLevel :
31
49
this . state . enthusiasmLevel - 1 > 0 ? this . state . enthusiasmLevel - 1 : 0
32
50
} ) ;
51
+
33
52
public getExclamationMarks = ( numChars : number ) =>
34
53
Array ( numChars + 1 ) . join ( "!" ) ;
35
54
@@ -64,21 +83,4 @@ export default class Hello extends React.Component<IProps, IState> {
64
83
}
65
84
}
66
85
67
- // styles
68
- const styles = StyleSheet . create ( {
69
- root : {
70
- alignItems : "center" ,
71
- alignSelf : "center"
72
- } ,
73
- buttons : {
74
- flexDirection : "row"
75
- } ,
76
- button : {
77
- flex : 1 ,
78
- paddingVertical : 0
79
- } ,
80
- greeting : {
81
- color : "#999" ,
82
- fontWeight : "bold"
83
- }
84
- } ) ;
86
+ export default Hello ;
You can’t perform that action at this time.
0 commit comments