Sofi
Sofi

Reputation: 21

React Hook "useNavigate" is called in function "welcome" that is neither a React function component nor a custom React Hook function

I am new to React and following a tutorial. I want to create a simple welcome page and have the continue button navigate to the next web page. I receive an error message of useNavigate is called in function welcome that is neither a react function component not a custom react hook function.

import React from "react";
import { AGREEMENT } from "../navigation/CONSTANTS";
import { Route, useNavigate, Routes } from "react-router-dom";

const welcome = () => {
  const navigate = useNavigate();

  return (
    <div>
      <div>Welcome!! </div>
      <button onClick={() => navigate(AGREEMENT)}>Continue</button>
    </div>
  );
};

export default welcome;

Upvotes: 2

Views: 4984

Answers (1)

krishnazden
krishnazden

Reputation: 1177

Capitilize function name welcome to Wecome

const Welcome = () => { ...  ...  };
export default Welcome;

Upvotes: 2

Related Questions