Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated and improved documentation #586

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,60 +37,68 @@ npm install --save react date-fns

You need to import skeleton and theme styles first.

```javascript
import 'react-date-range/dist/styles.css'; // main style file
import 'react-date-range/dist/theme/default.css'; // theme css file
```


### `DatePicker`
```javascript
import React from 'react';
import 'react-date-range/dist/styles.css'; // main style file
import 'react-date-range/dist/theme/default.css'; // theme css file
import { Calendar } from 'react-date-range';

class MyComponent extends Component {
handleSelect(date){
console.log(date); // native Date object

function App() {
const handleSelect(date){
console.log("dateObeject:", date); // native Date object
}
render(){
return (
<Calendar
return (
<div>
<Calendar
date={new Date()}
onChange={this.handleSelect}
onChange={handleSelect}
/>
)
}
</div>
);
}

```


### `DateRangePicker / DateRange`
```javascript
import React from 'react';
import 'react-date-range/dist/styles.css'; // main style file
import 'react-date-range/dist/theme/default.css'; // theme css file
import { DateRangePicker } from 'react-date-range';

class MyComponent extends Component {
handleSelect(ranges){
console.log(ranges);
// {
// selection: {
// startDate: [native Date Object],
// endDate: [native Date Object],
// }
// }
}
render(){
const selectionRange = {

function App() {
const selectionRange = {
startDate: new Date(),
endDate: new Date(),
key: 'selection',
}
return (
<DateRangePicker
ranges={[selectionRange]}
onChange={this.handleSelect}
/>
)
const handleSelect = (ranges) => {
console.log("ranges:", ranges);
// outputs:
// {
// selection: {
// startDate: [native Date Object],
// endDate: [native Date Object]
// }
// }
}
return (
<div>
<DateRangePicker
ranges={[selectionRange]}
onChange={handleSelect}
/>
</div>
);
}



```

### Options
Expand Down