Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am using react datepicker and I have a calendar icon that when you click it popups the calendar. I implemented where the calendar closes

I am using react datepicker and I have a calendar icon that when you click it popups the calendar. I implemented where the calendar closes when I click anywhere outside the calendar, but I want to close the calendar popup when I click the calendar icon as well. right now it goes in an out when i click the icon again.

here is relvant code:

const handleDateChange = (e, newDate) => {

e.preventDefault();

const date = new Date(dateformat(newDate,"isoDate", true)+'T00:00:00.000');

setCalendarDate(date);

history.push(`/${page}/${sport}/${newDate}`);

};

const handleClick = (e) => {

e.preventDefault();

setIsOpen(!isOpen)

};

const handleOutsideClick =(e)=>{

if(isOpen && !e.target.closest(".react-datepicker")){

setIsOpen(false)

}

}

DropdownToggle tag="div" className="date-choose pad-left-0 pad-right-0">

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions