I want to pop up a date picker when I click some text or an image.
I am using reactjs. I'm using the HTML input type="date"
not the React-datepicker library.
Here is my code:
import { useRef } from "react";
const add = () => {
const interviewDateRef = useRef();
const handleInterviewDateClick = () => {
interviewDateRef.current.focus();
};
return (
<>
<button onClick={handleInterviewDateClick}>Change Date</button>
<input type="date" ref={interviewDateRef} className="hidden" />
</>
);
};
export default add;
Here is the codesandbox.
I want the date picker to work normally, but also to appear when clicking on text or an image. How can I do that?
Thank you.