Skip to content

Commit 2014e0b

Browse files
committed
added fragment
1 parent aceea45 commit 2014e0b

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

demoApp/App.js

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {Component} from 'react';
1+
import React, {Component, Fragment} from 'react';
22
import {
33
Button,
44
View,
@@ -32,6 +32,10 @@ export default class App extends Component {
3232
type: 'day',
3333
value: '',
3434
},
35+
birthday_year: {
36+
type: 'year',
37+
value: '',
38+
},
3539
state: {
3640
type: 'state',
3741
value: '',
@@ -116,15 +120,16 @@ export default class App extends Component {
116120
{this.renderError('last_name')}
117121
</View>
118122

119-
<View
120-
onLayout={({nativeEvent}) => {
121-
this.setInputPosition({
122-
ids: ['birthday_month', 'birthday_day'],
123-
value: nativeEvent.layout.y,
124-
});
125-
}}>
123+
<Fragment>
126124
<Text>Birthday?</Text>
127-
<View style={styles.split}>
125+
<View
126+
onLayout={({nativeEvent}) => {
127+
this.setInputPosition({
128+
ids: ['birthday_month', 'birthday_day'],
129+
value: nativeEvent.layout.y,
130+
});
131+
}}
132+
style={styles.split}>
128133
<View style={{flex: 1, marginRight: 5}}>
129134
<TextInput
130135
style={styles.input}
@@ -146,7 +151,23 @@ export default class App extends Component {
146151
{this.renderError('birthday_day')}
147152
</View>
148153
</View>
149-
</View>
154+
<View
155+
onLayout={({nativeEvent}) => {
156+
this.setInputPosition({
157+
ids: ['birthday_year'],
158+
value: nativeEvent.layout.y,
159+
});
160+
}}>
161+
<TextInput
162+
style={styles.input}
163+
placeholder="Year"
164+
onChangeText={value => {
165+
this.onInputChange({id: 'birthday_year', value});
166+
}}
167+
/>
168+
{this.renderError('birthday_year')}
169+
</View>
170+
</Fragment>
150171

151172
<View
152173
onLayout={({nativeEvent}) => {

demoApp/validation/dictionary.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ export const validationDictionary = {
144144
},
145145
},
146146

147+
year: {
148+
presence: {
149+
allowEmpty: false,
150+
message: '^This is required',
151+
},
152+
numericality: {
153+
greaterThan: 1900,
154+
lessThanOrEqualTo: new Date().getFullYear(),
155+
message: '^Must be valid',
156+
},
157+
},
158+
147159
zip: {
148160
presence: {
149161
allowEmpty: false,

0 commit comments

Comments
 (0)