Skip to content

Display selected Day from the Calendar #869

Closed Answered by onemanwenttomow
Leon910 asked this question in Web
Discussion options

You must be logged in to vote

I would consider checking if the selectedDate is in the query string when you initialise the component.

i.e. something like this (if it doesn't exist on the query string then use the current date).

const [selectedDate, setSelectedDate] = useState(() => {
  const currentDate = format(new Date(), "yyyy-MM-dd");
  return router.query.selectedDate || currentDate;
});

Hopefully this helps

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Leon910
Comment options

Answer selected by onemanwenttomow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants