Skip to content

Set the endDate to an empty string, after it was changed to an endDate that is smaller than the startDate doesn't work, because it renders two times #742

Discussion options

You must be logged in to vote

Hi @ahohnsen & @JessicaLoers, first of all, thank you for your input and the feedback! 🐸

We added the handler function + the state for the end date value to the onSubmit function, set the value of the End Date to endDateValue from the state and now everything works ✌️

Here is the code:

import CancelButton from "@/components/CancelButton";
import CreateButton from "@/components/CreateButton";
import { useRouter } from "next/router";
import useSWR from "swr";
import { useState } from "react";

const fetcher = (...args) => fetch(...args).then((res) => res.json());

export default function TripDetailsForm() {
  const { mutate } = useSWR("/api/trips");
  const router = useRouter();

  const [e…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Dskottke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
1 participant