Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
74
rated 0 times [  76] [ 2]  / answers: 1 / hits: 12191  / 3 Years ago, tue, november 23, 2021, 12:00:00

I am trying to implement a home page for my react.js website. My layout is fine and my code compiles without problems.


However when I click my button I am getting the following error on the website application: TypeError: navigate.push is not a function on the line that says navigate.push("/quiz")


I am new to react and if anyone can help me I would be greatful!


Here is my code:


import { Button } from "@material-ui/core";
import { Container } from "@material-ui/core";
import { useNavigate } from "react-router-dom";
import "./Home.css";

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

const sendSubmit = () => {
navigate.push("/quiz");
};
return (
<Container className="content">
<h1 id="quiz-title">Phishing Quiz</h1>
<h2 class="question-text">
Do you think you can beat our phishing quiz?
</h2>
<p className="description">
{" "}
There are many social engineering attacks on internet however not all of
them are good enough to trick users. However there are some scams that
are identical to original websites and usually most of the users get
tricked by them.
</p>
<p className="description">
Do you think you are smart enough to handle these attacks?
</p>
<p className="description">
We are challenging you with our phishing quiz which will show you
examples of really good social engineering attacks on internet. We hope
you can pass!
</p>
<p>""</p>
<Button
className="button"
variant="contained"
color="primary"
size="large"
onClick={sendSubmit}
>
Start Quiz
</Button>
</Container>
);
};

export default Home;


More From » node.js

 Answers
39

can check with below code


import {useNavigate} from 'react-router-dom';

and inside Home arrow function


const navigate = useNavigate();

const sendSubmit = () => {
navigate("/quiz");
};

[#664] Thursday, November 11, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
collinisaaka

Total Points: 194
Total Questions: 105
Total Answers: 104

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;