Skip to content

OnClick Event in React Calendar #113

Answered by ahohnsen
therealchrismcfly asked this question in Web
Discussion options

You must be logged in to vote

Hey Chris,

Instead of calling setDate on the onChange event, you can call another function. This function could for example set the date and execute further commands:

	function handleChange(selectedDate) {
		setDate(selectedDate);

	}

	return (
		<>
			<h1>React Calendar</h1>
			<Calendar onChange={handleChange} value={date} />
			<p>SelectedDate: {date.toDateString()}</p>
		</>
	);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ahohnsen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
2 participants