Skip to content

Commit df91a40

Browse files
authored
Merge pull request #44 from s2t2/master
Add import example to README
2 parents 7bed292 + 091f744 commit df91a40

File tree

1 file changed

+39
-24
lines changed

1 file changed

+39
-24
lines changed

README.md

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,45 @@ Check [index.android.js](https://github.com/xgfe/react-native-datepicker/blob/ma
1616
## Usage
1717

1818
```javascript
19-
<DatePicker
20-
style={{width: 200}}
21-
date={this.state.date}
22-
mode="date"
23-
placeholder="select date"
24-
format="YYYY-MM-DD"
25-
minDate="2016-05-01"
26-
maxDate="2016-06-01"
27-
confirmBtnText="Confirm"
28-
cancelBtnText="Cancel"
29-
customStyles={{
30-
dateIcon: {
31-
position: 'absolute',
32-
left: 0,
33-
top: 4,
34-
marginLeft: 0
35-
},
36-
dateInput: {
37-
marginLeft: 36
38-
},
39-
... // You can check the source to find the other keys.
40-
}}
41-
onDateChange={(date) => {this.setState({date: date})}}
42-
/>
19+
20+
import React, { Component } from 'react'
21+
import DatePicker from 'react-native-datepicker'
22+
23+
export default class MyDatePicker extends Component {
24+
constructor(props){
25+
super(props)
26+
this.state = {date:"2016-05-15"}
27+
}
28+
29+
render(){
30+
return (
31+
<DatePicker
32+
style={{width: 200}}
33+
date={this.state.date}
34+
mode="date"
35+
placeholder="select date"
36+
format="YYYY-MM-DD"
37+
minDate="2016-05-01"
38+
maxDate="2016-06-01"
39+
confirmBtnText="Confirm"
40+
cancelBtnText="Cancel"
41+
customStyles={{
42+
dateIcon: {
43+
position: 'absolute',
44+
left: 0,
45+
top: 4,
46+
marginLeft: 0
47+
},
48+
dateInput: {
49+
marginLeft: 36
50+
}
51+
// ... You can check the source to find the other keys.
52+
}}
53+
onDateChange={(date) => {this.setState({date: date})}}
54+
/>
55+
)
56+
}
57+
}
4358
```
4459

4560
You can check [index.js](https://github.com/xgfe/react-native-datepicker/blob/master/index.android.js) in the Example for detail.

0 commit comments

Comments
 (0)