Closed bsalpsingh closed 3 years ago
defaultDate
props to <Calendar />
component.
Here is a working example for setting default date from the state:import React, { useState } from "react";
import Calendar from "@sbmdkl/nepali-datepicker-reactjs";
import "@sbmdkl/nepali-datepicker-reactjs/dist/index.css";
function App() {
const [date, setDate] = useState("");
const [myDate, setMyDate] = useState("2075-10-12");
const handleDate = ({ bsDate, adDate }) => {
setDate({ date: bsDate });
};
return (
<div>
<h1>Nepali Date Picker for React</h1>
<Calendar defaultDate={myDate} onChange={handleDate} theme="deepdark" />
</div>
);
}
export default App;
defaultDate doesnt update on rerender. it only works if default date exists in initial render
I have got 2 datepickers, I am trying to set default date of second date picker when date has been selected on the first datepicker. But it default date on second datepicker doesnt get updated. Is there any workaround for this? https://codesandbox.io/s/zen-monad-s5t7u5?file=/src/App.js
Unable to set the default value from states as it always starts from today's date....is there a way to pass dates from States to show on the input filed...