Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Login.js #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/src/components/Authentication/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { VStack } from "@chakra-ui/layout";
import { useState } from "react";
import axios from "axios";
import { useToast } from "@chakra-ui/react";
import { useHistory } from "react-router-dom";
import { useNavigate } from "react-router-dom"; // useHistory is not supported in react-router-dom v6
import { ChatState } from "../../Context/ChatProvider";

const Login = () => {
Expand All @@ -16,7 +16,7 @@ const Login = () => {
const [password, setPassword] = useState();
const [loading, setLoading] = useState(false);

const history = useHistory();
const navigate = useNavigate();
const { setUser } = ChatState();

const submitHandler = async () => {
Expand Down Expand Up @@ -56,7 +56,7 @@ const Login = () => {
setUser(data);
localStorage.setItem("userInfo", JSON.stringify(data));
setLoading(false);
history.push("/chats");
navigate("/chats");
} catch (error) {
toast({
title: "Error Occured!",
Expand Down