@@ -76,7 +76,7 @@ export default class App extends Component {
7676
7777 renderError ( id ) {
7878 const { inputs} = this . state ;
79- if ( inputs [ id ] . errorLabel && inputs [ id ] . touched ) {
79+ if ( inputs [ id ] . errorLabel ) {
8080 return < Text style = { styles . error } > { inputs [ id ] . errorLabel } </ Text > ;
8181 }
8282 return null ;
@@ -94,6 +94,7 @@ export default class App extends Component {
9494 this . onInputChange ( { id : 'first_name' , value} ) ;
9595 } }
9696 errorLabel = { inputs . first_name . errorLabel }
97+ touched = { inputs . first_name . touched }
9798 onLayout = { ( { nativeEvent} ) => {
9899 this . setInputPosition ( {
99100 ids : [ 'first_name' ] ,
@@ -108,6 +109,7 @@ export default class App extends Component {
108109 this . onInputChange ( { id : 'last_name' , value} ) ;
109110 } }
110111 errorLabel = { inputs . last_name . errorLabel }
112+ touched = { inputs . last_name . touched }
111113 onLayout = { ( { nativeEvent} ) => {
112114 this . setInputPosition ( {
113115 ids : [ 'last_name' ] ,
@@ -132,6 +134,7 @@ export default class App extends Component {
132134 this . onInputChange ( { id : 'birthday_month' , value} ) ;
133135 } }
134136 errorLabel = { inputs . birthday_month . errorLabel }
137+ touched = { inputs . birthday_month . touched }
135138 placeholder = "Month"
136139 keyboardType = "number-pad"
137140 />
@@ -142,6 +145,7 @@ export default class App extends Component {
142145 this . onInputChange ( { id : 'birthday_day' , value} ) ;
143146 } }
144147 errorLabel = { inputs . birthday_day . errorLabel }
148+ touched = { inputs . birthday_day . touched }
145149 placeholder = "Day"
146150 keyboardType = "number-pad"
147151 />
@@ -152,6 +156,7 @@ export default class App extends Component {
152156 this . onInputChange ( { id : 'birthday_year' , value} ) ;
153157 } }
154158 errorLabel = { inputs . birthday_year . errorLabel }
159+ touched = { inputs . birthday_year . touched }
155160 placeholder = "Year"
156161 keyboardType = "number-pad"
157162 />
@@ -163,6 +168,7 @@ export default class App extends Component {
163168 this . onInputChange ( { id : 'state' , value} ) ;
164169 } }
165170 errorLabel = { inputs . state . errorLabel }
171+ touched = { inputs . state . touched }
166172 onLayout = { ( { nativeEvent} ) => {
167173 this . setInputPosition ( {
168174 ids : [ 'state' ] ,
@@ -179,6 +185,7 @@ export default class App extends Component {
179185 this . onInputChange ( { id : 'zip' , value} ) ;
180186 } }
181187 errorLabel = { inputs . zip . errorLabel }
188+ touched = { inputs . zip . touched }
182189 onLayout = { ( { nativeEvent} ) => {
183190 this . setInputPosition ( {
184191 ids : [ 'zip' ] ,
@@ -242,4 +249,4 @@ const styles = StyleSheet.create({
242249 color : 'red' ,
243250 fontSize : 12 ,
244251 } ,
245- } ) ;
252+ } ) ;
0 commit comments