-
-
Notifications
You must be signed in to change notification settings - Fork 761
Closed
Description
If we use a state variable for startMonth, the day picker doesn't update the initial month
Code
import { DayPicker } from 'react-day-picker';
import {useState, useEffect} from 'react';
import 'react-day-picker/dist/style.css';
import "./styles.css";
export default function App() {
const [startMonth, setStartMonth] = useState('');
useEffect(() => {
setStartMonth(new Date(2024,2));
}, [])
return (
<div className="App">
<DayPicker
mode="single"
className="day-picker"
startMonth={startMonth}
defaultMonth={startMonth}
/>
</div>
);
}
sandbox link - https://codesandbox.io/p/sandbox/strange-benz-vsh96j
Expected Behavior
The initial month in calendar updates if the state variable is updated
Actual Behavior
The initial month displayed s the value set during state variable
Screenshots
Metadata
Metadata
Assignees
Labels
bugBug or Bug fixesBug or Bug fixes