themesberg / themesberg/flowbite-react
Datepicker update value
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 506
- PR merge metrics
- No merged PRs in 30d
Description
Steps to reproduce
give datepicker a date, then trying to change outside of the datepicker
Current behavior
Even though the variable date changes, the value inside the datepicker does not change
Expected behavior
Datepicker should show the date that is setted as the current date on the variable
Context
When clicking on the arrows it should go a dar forward or back
I deleted parts of the code that are not relevant so divs might be broken
import { useState } from "react";
import { Datepicker } from "flowbite-react";
const Component= () => {
const [date, setDate] = useState(new Date());
const goBackOneDay = () => {
setDate((prevDate) => {
const newDate = new Date(prevDate);
newDate.setDate(newDate.getDate() - 1);
return newDate;
});
};
const goForwardOneDay = () => {
setDate((prevDate) => {
const newDate = new Date(prevDate);
newDate.setDate(newDate.getDate() + 1);
return newDate;
});
};
const testDate = () => {
console.log(date);
};
return (
<div className="trading-tool grid grid-cols-3 grid-rows-[auto_3fr_1fr] gap-2.5 h-screen bg-gray-800 text-white p-2.5">
{/* Header row for the title and date picker */}
<div className="col-span-3 flex items-center p-2.5 text-lg border-b border-gray-600">
<span>Component</span>
<div className="flex-grow flex justify-center items-center">
<button onClick={goBackOneDay}><</button>
<Datepicker date={date} title="Flowbite Datepicker" />
<button onClick={goForwardOneDay}>></button>
</div>
<button onClick={testDate}>Test</button>
</div>
</div>
);
};
export default Component;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the Datepicker component named in the report as the entry point; first reproduce the external date change with the arrow buttons and compare the prop value with the displayed value. Done means the picker updates when its date prop changes, while its existing navigation behavior still works; the report names no files or tests to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100