[BUGFIX] Fix re-rendering callbacks (#1445)

b34b10322b introduced a regression where including deps in the associated useCallback functions would cause React to re-render components.
This resulted in unexpected symptoms like multiple Duo push requests, even if a successful or errored request had already been received.

Empty deps/no re-rendering for the respective callbacks is an expected result therefore we can safely ignore these issues the linter is suggesting needs to be fixed.
pull/1444/head^2
Amir Zarrinkafsh 2020-11-11 14:51:42 +11:00 committed by GitHub
parent 2b1baacd82
commit 2834f3f8e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -31,8 +31,10 @@ const OneTimePasswordMethod = function (props: Props) {
const redirectionURL = useRedirectionURL();
const { onSignInSuccess, onSignInError } = props;
const onSignInErrorCallback = useCallback(onSignInError, [onSignInError]);
const onSignInSuccessCallback = useCallback(onSignInSuccess, [onSignInSuccess]);
/* eslint-disable react-hooks/exhaustive-deps */
const onSignInErrorCallback = useCallback(onSignInError, []);
const onSignInSuccessCallback = useCallback(onSignInSuccess, []);
/* eslint-enable react-hooks/exhaustive-deps */
const signInFunc = useCallback(async () => {
if (props.authenticationLevel === AuthenticationLevel.TwoFactor) {

View File

@ -30,8 +30,10 @@ const PushNotificationMethod = function (props: Props) {
const mounted = useIsMountedRef();
const { onSignInSuccess, onSignInError } = props;
const onSignInErrorCallback = useCallback(onSignInError, [onSignInError]);
const onSignInSuccessCallback = useCallback(onSignInSuccess, [onSignInSuccess]);
/* eslint-disable react-hooks/exhaustive-deps */
const onSignInErrorCallback = useCallback(onSignInError, []);
const onSignInSuccessCallback = useCallback(onSignInSuccess, []);
/* eslint-enable react-hooks/exhaustive-deps */
const signInFunc = useCallback(async () => {
if (props.authenticationLevel === AuthenticationLevel.TwoFactor) {

View File

@ -38,8 +38,10 @@ const SecurityKeyMethod = function (props: Props) {
const [timerPercent, triggerTimer,] = useTimer(signInTimeout * 1000 - 500);
const { onSignInSuccess, onSignInError } = props;
const onSignInErrorCallback = useCallback(onSignInError, [onSignInError]);
const onSignInSuccessCallback = useCallback(onSignInSuccess, [onSignInSuccess]);
/* eslint-disable react-hooks/exhaustive-deps */
const onSignInErrorCallback = useCallback(onSignInError, []);
const onSignInSuccessCallback = useCallback(onSignInSuccess, []);
/* eslint-enable react-hooks/exhaustive-deps */
const doInitiateSignIn = useCallback(async () => {
// If user is already authenticated, we don't initiate sign in process.