[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.
This commit is contained in:
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 redirectionURL = useRedirectionURL();
const { onSignInSuccess, onSignInError } = props; const { onSignInSuccess, onSignInError } = props;
const onSignInErrorCallback = useCallback(onSignInError, [onSignInError]); /* eslint-disable react-hooks/exhaustive-deps */
const onSignInSuccessCallback = useCallback(onSignInSuccess, [onSignInSuccess]); const onSignInErrorCallback = useCallback(onSignInError, []);
const onSignInSuccessCallback = useCallback(onSignInSuccess, []);
/* eslint-enable react-hooks/exhaustive-deps */
const signInFunc = useCallback(async () => { const signInFunc = useCallback(async () => {
if (props.authenticationLevel === AuthenticationLevel.TwoFactor) { if (props.authenticationLevel === AuthenticationLevel.TwoFactor) {

View File

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

View File

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