Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next month button doesn't work. #15

Open
longman0512 opened this issue Mar 8, 2021 · 4 comments
Open

Next month button doesn't work. #15

longman0512 opened this issue Mar 8, 2021 · 4 comments

Comments

@longman0512
Copy link

No description provided.

@johnny-minty
Copy link

@longman0512 You need to ensure you handle the onChange event properly and set/update the 'displayedDate' prop correctly

@aldiinugroho
Copy link

maybe dates.displayedDate will be undefined, therefore we need to give certain conditions.

try this maybe it help:

const setDates = (dates) => {
        if (dates.startDate != undefined) {
            setStartDate(dates.startDate)
        }

        if (dates.displayedDate != undefined) {
            setDisplayedDate(dates.displayedDate)
        }

        if (dates.endDate != undefined) {
            setEndDate(dates.endDate)
        }
    };

@fcamargo10
Copy link

maybe dates.displayedDate will be undefined, therefore we need to give certain conditions.

try this maybe it help:

const setDates = (dates) => {
        if (dates.startDate != undefined) {
            setStartDate(dates.startDate)
        }

        if (dates.displayedDate != undefined) {
            setDisplayedDate(dates.displayedDate)
        }

        if (dates.endDate != undefined) {
            setEndDate(dates.endDate)
        }
    };

Work's fine.

@shoaibshebi
Copy link

Set Like that

👇👇😊

const [dateObj, setDateObj] = useState({
    startDate: null,
    endDate: null,
    displayedDate: moment(),
  });
  
  
<DateRangePicker
            onChange={dates => {
              console.log('dates ------------------', dates);
              setDateObj({
                startDate:
                  'startDate' in dates
                    ? moment(dates.startDate)
                    : dateObj?.startDate,
                endDate:
                  'endDate' in dates ? moment(dates.endDate) : dateObj?.endDate,
                displayedDate:
                  'displayedDate' in dates
                    ? moment(dates.displayedDate)
                    : dateObj?.displayedDate,
              });
            }}
            endDate={dateObj?.endDate}
            startDate={dateObj?.startDate}
            displayedDate={dateObj?.displayedDate}
            range={true}
>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants