gpbl / gpbl/react-day-picker

The `selected` prop is not working without setting `onSelect`

Open
#2,690 7 comments 0 reactions 2 assignees Claimed by @gpbl View on GitHub
breaking change
Dominant language
TypeScript
Stars
6.9k
Forks
780
Avg merge
2d 3h
Merged PRs (30d)
3

Description

## To reproduce
**stackblitz Link**: https://stackblitz.com/edit/vitejs-vite-rdyvfyjg?file=src%2FApp.tsx

```tsx
import { useState } from 'react';
import { DayPicker } from 'react-day-picker';
import 'react-day-picker/style.css';

const DAY_IN_MS = 24 * 60 * 60 * 1000;

function App() {
const [range, setRange] = useState({
from: new Date(),
to: new Date(),
});

const changerPrev = () => {
setRange({
from: new Date(range.from.getTime() - DAY_IN_MS),
to: range.to,
});
};

return (
<>
changerPrev()}>prev
{/* it doesn't work */}

{/* it work */}
void 0} />

);
}

export default App;
```

## Actual Behavior

In the first case, the selected value does not change.
In the second case, the selected value changes.

## Expected Behavior

In both the first and second cases, the selected value should change.

## Screenshots

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.