Fixed redirect issue

This commit is contained in:
2022-11-29 04:53:29 +00:00
parent 45cf281c91
commit 5cf4b66894
5 changed files with 188 additions and 208 deletions
+6 -3
View File
@@ -1,5 +1,5 @@
import React, { useContext, useRef } from 'react';
import { Link, Navigate } from 'react-router-dom';
import { Link, useNavigate } from 'react-router-dom';
import queryString from 'query-string';
import ApplyToBody from '../utilities/apply-to-body';
@@ -7,6 +7,9 @@ import ApplyToBody from '../utilities/apply-to-body';
import { TokenContext } from '../utilities/token-provider';
const Reset = props => {
//history
const navigate = useNavigate();
//context
const authTokens = useContext(TokenContext);
@@ -15,7 +18,7 @@ const Reset = props => {
//misplaced?
if (authTokens.accessToken || !query.email || !query.token) {
return <Navigate to='/' />;
navigate("/");
}
//refs
@@ -42,7 +45,7 @@ const Reset = props => {
//redirect
if (redirect) {
props.history.push('/');
navigate("/");
}
}}>
<input type='password' name='password' placeholder='New Password' ref={passwordRef} />