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

Updated react router dom to v6 #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
18,987 changes: 18,987 additions & 0 deletions frontend/package-lock.json

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@
"proxy": "http://127.0.0.1:5000",
"private": true,
"dependencies": {
"@chakra-ui/icons": "^1.0.13",
"@chakra-ui/react": "^1.6.2",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@chakra-ui/icons": "^2.0.19",
"@chakra-ui/react": "^2.6.1",
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"axios": "^0.21.1",
"framer-motion": "^4",
"react": "^17.0.2",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"axios": "^1.4.0",
"framer-motion": "^10.12.9",
"react": "^18.2.0",
"react-chips": "^0.8.0",
"react-dom": "^17.0.2",
"react-dom": "^18.2.0",
"react-lottie": "^1.2.3",
"react-notification-badge": "^1.5.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-router-dom": "^6.11.1",
"react-script": "^2.0.5",
"react-scripts": "^5.0.1",
"react-scrollable-feed": "^1.3.1",
"socket.io-client": "^4.1.2",
"web-vitals": "^1.0.1"
"web-vitals": "^3.3.1"
},
"scripts": {
"start": "react-scripts start",
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import "./App.css";
import Homepage from "./Pages/Homepage";
import { Route } from "react-router-dom";
import Chatpage from "./Pages/Chatpage";

import { Routes } from "react-router-dom";
function App() {
return (
<div className="App">
<Route path="/" component={Homepage} exact />
<Route path="/chats" component={Chatpage} />
<Routes>
<Route path="/" element={Homepage} />
<Route path="/chats" element={Chatpage} />
</Routes>
</div>
);
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/Context/ChatProvider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { createContext, useContext, useEffect, useState } from "react";
import { useHistory } from "react-router-dom";
import { useNavigate } from "react-router-dom";

const ChatContext = createContext();

Expand All @@ -9,15 +9,15 @@ const ChatProvider = ({ children }) => {
const [notification, setNotification] = useState([]);
const [chats, setChats] = useState();

const history = useHistory();
const navigate = useNavigate();

useEffect(() => {
const userInfo = JSON.parse(localStorage.getItem("userInfo"));
setUser(userInfo);

if (!userInfo) history.push("/");
if (!userInfo) navigate("/");
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [history]);
}, [navigate]);

return (
<ChatContext.Provider
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/Pages/Homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import {
Text,
} from "@chakra-ui/react";
import { useEffect } from "react";
import { useHistory } from "react-router";
import { useNavigate } from "react-router";
import Login from "../components/Authentication/Login";
import Signup from "../components/Authentication/Signup";

function Homepage() {
const history = useHistory();
const navigate = useNavigate();

useEffect(() => {
const user = JSON.parse(localStorage.getItem("userInfo"));

if (user) history.push("/chats");
}, [history]);
if (user) navigate("/chats");
}, [navigate]);

return (
<Container maxW="xl" centerContent>
Expand Down
7 changes: 4 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";

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

const history = useHistory();
const navigate = useNavigate();

const submitHandler = async () => {
setLoading(true);
Expand Down Expand Up @@ -55,7 +55,8 @@ const Login = () => {
});
localStorage.setItem("userInfo", JSON.stringify(data));
setLoading(false);
history.push("/chats");

navigate('/chats');
} catch (error) {
toast({
title: "Error Occured!",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Authentication/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { VStack } from "@chakra-ui/layout";
import { useToast } from "@chakra-ui/toast";
import axios from "axios";
import { useState } from "react";
import { useHistory } from "react-router";
import { useNavigate } from "react-router";

const Signup = () => {
const [show, setShow] = useState(false);
const handleClick = () => setShow(!show);
const toast = useToast();
const history = useHistory();
const navigate = useNavigate();

const [name, setName] = useState();
const [email, setEmail] = useState();
Expand Down Expand Up @@ -70,7 +70,7 @@ const Signup = () => {
});
localStorage.setItem("userInfo", JSON.stringify(data));
setPicLoading(false);
history.push("/chats");
navigate('/chats');
} catch (error) {
toast({
title: "Error Occured!",
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/components/miscellaneous/SideDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { Tooltip } from "@chakra-ui/tooltip";
import { BellIcon, ChevronDownIcon } from "@chakra-ui/icons";
import { Avatar } from "@chakra-ui/avatar";
import { useHistory } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import { useState } from "react";
import axios from "axios";
import { useToast } from "@chakra-ui/toast";
Expand Down Expand Up @@ -49,11 +49,12 @@ function SideDrawer() {

const toast = useToast();
const { isOpen, onOpen, onClose } = useDisclosure();
const history = useHistory();
const navigate = useNavigate();

const logoutHandler = () => {
localStorage.removeItem("userInfo");
history.push("/");

navigate('/');
};

const handleSearch = async () => {
Expand Down
Loading