Reputation: 21
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
Reputation: 1177
Capitilize function name welcome to Wecome
const Welcome = () => { ... ... };
export default Welcome;
Upvotes: 2