Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

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