Datepicker update value

Đang mở
#1,388 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Sử dụng component Datepicker được nêu trong báo cáo làm điểm bắt đầu; trước tiên tái hiện việc thay đổi ngày từ bên ngoài bằng các nút mũi tên và so sánh giá trị prop với giá trị được hiển thị. Được xem là hoàn tất khi picker cập nhật lúc date prop của nó thay đổi, đồng thời hành vi điều hướng hiện có vẫn hoạt động; báo cáo không nêu file hoặc test nào cần chạy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
image
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}>&lt;</button>
          <Datepicker date={date} title="Flowbite Datepicker" />
          <button onClick={goForwardOneDay}>&gt;</button>
        </div>
        <button onClick={testDate}>Test</button>
      </div>

    </div>
  );
};

export default Component;

Ngôn ngữ chính
TypeScript
Star
2.1k
Fork
502
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của themesberg/flowbite-react

Tất cả issue của themesberg/flowbite-react

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.