Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why NavigateFunction type is shown cannot be found when assigning it to react-router navigate?

I am trying to migrate my functions from function components to a separate file.

Function component code:

const Signup = () => {
  let navigate = useNavigate();   

  return (
    ............
    <Form className="SignupForm" onSubmit={() => onSignupHandler(navigate)}>
  )
}

Here is the onSignUpHandler function code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

export const onSignupHandler = (navigate: NavigateFunction) => {
  // Some code ...............
};

I am trying to assign navigate type of NavigateFunction but I get error as Cannot find name 'NavigateFunction'.

>Solution :

You are missing it the imports. Add to the file where onSignUpHandler is:

import { NavigateFunction } from "react-router-dom";
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading