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 11import * as React from "react" ;
22import { Button , StyleSheet , Text , View } from "react-native" ;
33
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+
423export interface IProps {
524 name : string ;
625 enthusiasmLevel ?: number ;
@@ -10,26 +29,26 @@ interface IState {
1029 enthusiasmLevel : number ;
1130}
1231
13- export default class Hello extends React . Component < IProps , IState > {
32+ class Hello extends React . Component < IProps , IState > {
1433 constructor ( props : IProps ) {
1534 super ( props ) ;
16-
1735 if ( ( props . enthusiasmLevel || 0 ) <= 0 ) {
1836 throw new Error ( "You could be a little more enthusiastic. :D" ) ;
1937 }
20-
2138 this . state = {
2239 enthusiasmLevel : props . enthusiasmLevel || 1
2340 } ;
2441 }
2542
2643 public onIncrement = ( ) =>
2744 this . setState ( { enthusiasmLevel : this . state . enthusiasmLevel + 1 } ) ;
45+
2846 public onDecrement = ( ) =>
2947 this . setState ( {
3048 enthusiasmLevel :
3149 this . state . enthusiasmLevel - 1 > 0 ? this . state . enthusiasmLevel - 1 : 0
3250 } ) ;
51+
3352 public getExclamationMarks = ( numChars : number ) =>
3453 Array ( numChars + 1 ) . join ( "!" ) ;
3554
@@ -64,21 +83,4 @@ export default class Hello extends React.Component<IProps, IState> {
6483 }
6584}
6685
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