1
1
import * as React from "react" ;
2
2
import { Button , StyleSheet , Text , View } from "react-native" ;
3
3
4
- // styles
5
4
const styles = StyleSheet . create ( {
6
5
root : {
7
6
alignItems : "center" ,
@@ -20,35 +19,23 @@ const styles = StyleSheet.create({
20
19
}
21
20
} ) ;
22
21
23
- export interface IProps {
22
+ interface Props {
24
23
name : string ;
25
24
enthusiasmLevel ?: number ;
26
25
}
27
26
28
- export interface IState {
27
+ export interface State {
29
28
enthusiasmLevel : number ;
30
29
}
31
30
32
- class Hello extends React . Component < IProps , IState > {
33
- constructor ( props : IProps ) {
31
+ export class Welcome extends React . Component < Props , State > {
32
+ constructor ( props : Props ) {
34
33
super ( props ) ;
35
34
this . state = {
36
35
enthusiasmLevel : props . enthusiasmLevel || 1
37
36
} ;
38
37
}
39
38
40
- public onIncrement = ( ) =>
41
- this . setState ( { enthusiasmLevel : this . state . enthusiasmLevel + 1 } ) ;
42
-
43
- public onDecrement = ( ) =>
44
- this . setState ( {
45
- enthusiasmLevel :
46
- this . state . enthusiasmLevel - 1 > 0 ? this . state . enthusiasmLevel - 1 : 0
47
- } ) ;
48
-
49
- public getExclamationMarks = ( numChars : number ) =>
50
- Array ( numChars + 1 ) . join ( "!" ) ;
51
-
52
39
public render ( ) {
53
40
return (
54
41
< View style = { styles . root } >
@@ -78,6 +65,16 @@ class Hello extends React.Component<IProps, IState> {
78
65
</ View >
79
66
) ;
80
67
}
81
- }
82
68
83
- export default Hello ;
69
+ private onIncrement = ( ) =>
70
+ this . setState ( { enthusiasmLevel : this . state . enthusiasmLevel + 1 } ) ;
71
+
72
+ private onDecrement = ( ) =>
73
+ this . setState ( {
74
+ enthusiasmLevel :
75
+ this . state . enthusiasmLevel - 1 > 0 ? this . state . enthusiasmLevel - 1 : 0
76
+ } ) ;
77
+
78
+ private getExclamationMarks = ( numChars : number ) =>
79
+ Array ( numChars + 1 ) . join ( "!" ) ;
80
+ }
0 commit comments