From 31d3909e80745727606c83aaf8964f780417b050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Sat, 15 Apr 2023 22:12:54 +0200 Subject: [PATCH] fixed the new useNavigation hook usage --- front/views/AuthenticationView.tsx | 10 ++++++++-- front/views/StartPageView.tsx | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/front/views/AuthenticationView.tsx b/front/views/AuthenticationView.tsx index e707cb9..4221b11 100644 --- a/front/views/AuthenticationView.tsx +++ b/front/views/AuthenticationView.tsx @@ -7,6 +7,7 @@ import { Center, Button, Text } from 'native-base'; import SigninForm from "../components/forms/signinform"; import SignupForm from "../components/forms/signupform"; import TextButton from "../components/TextButton"; +import { useNavigation } from "../Navigation"; const hanldeSignin = async (username: string, password: string, apiSetter: (accessToken: string) => void): Promise => { try { @@ -32,9 +33,14 @@ const handleSignup = async (username: string, password: string, email: string, a } }; -const AuthenticationView = ({ route, navigation }: any) => { +const AuthenticationView = () => { + const navigation = useNavigation(); const dispatch = useDispatch(); - const isSignup = route.params?.isSignup ?? false; + const params = navigation.getState().routes.find((route) => { + // this is not ideal way to check if we are on login page + return route.name === "Login"; + }).params ?? {}; + const isSignup = params?.isSignup ?? false; const [mode, setMode] = React.useState<"signin" | "signup">(isSignup ? "signup" : "signin"); return ( diff --git a/front/views/StartPageView.tsx b/front/views/StartPageView.tsx index e9dfada..cd9c1af 100644 --- a/front/views/StartPageView.tsx +++ b/front/views/StartPageView.tsx @@ -45,7 +45,7 @@ const imgLogo = "https://chromacase.studio/wp-content/uploads/2023/03/cropped-cropped-splashLogo-280x300.png"; const StartPageView = () => { - const navigate = useNavigation(); + const navigation = useNavigation(); const screenSize = useBreakpointValue({ base: "small", md: "big" }); const isSmallScreen = screenSize === "small"; const dispatch = useDispatch();