#Refresh does not exist on type NextRouter

1 messages · Page 1 of 1 (latest)

tawdry condor
#

Hey, I'm having success with this:

"use client";

import { useRef } from "react";
import { useRouter } from "next/navigation";
import TextInput from "components/shared/input/TextInput";
import Button from "components/shared/input/Button";

import { createCustomer } from "api/customers/client";

import type { FormEvent } from "react";

interface CustomerFormProps {}

export default function CustomerForm(props: CustomerFormProps) {
  const router = useRouter();
  const formRef = useRef<HTMLFormElement>(null);

  const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
    event.preventDefault();

    const form = event.currentTarget;
    const data = new FormData(form);

    const customer = {
      name: (data.get("name") as string) || "",
      email: (data.get("email") as string) || "",
      phone: (data.get("phone") as string) || "",
      twitter: (data.get("twitter") as string) || "",
    };

    await createCustomer(customer);

    form.reset();

    router.refresh();
  };

....
thorn tide
#

What would be my mistake?

#

I wonder.

#

My bad Sorry I was importing useRouter from next/router instead of next/navigation

tawdry condor
#

There you go 🙂

thorn tide
#

Thanks!

tawdry condor
#

I knew it was something in that block..

thorn tide
#

Yeah

tawdry condor
#

Figured you already had "use client";

thorn tide
#

Yes

tawdry condor
#

Well great!

thorn tide
#

I saw a large table on your GitHub profile README.
Could you tell me more about it?

tawdry condor
#

Those are a list of projects that I have put together over the last year using different technologies. Each project had a deadline and I spent between 4 and 10 hours on each one.

#

Some of them I've updated afterwards, refactoring based on what I learn later on.

#

The projects were chosen every week or two by a discord group vote. Then between 2 and 10 people would complete projects.

#

Those were mostly my submissions.

thorn tide
#

Oh nice Thanks for sharing

#

Its inspiring 🥹

tawdry condor
#

What has been great, is the fact that I have a pretty good library of examples now that I can share with others. So it was easy for me to pull up this example for you.