Skip to content

fix(auth): remove unnecessary useEffect+useState for AUTH_TYPE constant#978

Closed
tysoncung wants to merge 1 commit intoMODSetter:mainfrom
tysoncung:fix/941-remove-unnecessary-useeffect-login
Closed

fix(auth): remove unnecessary useEffect+useState for AUTH_TYPE constant#978
tysoncung wants to merge 1 commit intoMODSetter:mainfrom
tysoncung:fix/941-remove-unnecessary-useeffect-login

Conversation

@tysoncung
Copy link

@tysoncung tysoncung commented Mar 25, 2026

Problem

LocalLoginForm.tsx stores the AUTH_TYPE module-level constant into React state via a useEffect on mount. Since AUTH_TYPE is a static import that never changes at runtime, this pattern is unnecessary and causes an extra render cycle on mount.

Solution

Replace the useState + useEffect pattern with a direct constant assignment:

// Before
const [authType, setAuthType] = useState<string | null>(null);
useEffect(() => { setAuthType(AUTH_TYPE); }, []);

// After
const authType = AUTH_TYPE;

Also removed the now-unused useEffect import.

Changes

  • surfsense_web/app/(home)/login/LocalLoginForm.tsx:
    • Removed useEffect import (no longer needed)
    • Replaced useState/useEffect with direct constant
    • No behavioral change — authType still resolves to the same value

Closes #941

High-level PR Summary

This PR simplifies the LocalLoginForm component by removing an unnecessary useEffect and useState pattern that was used to store a static constant (AUTH_TYPE) in React state. The constant is now assigned directly, eliminating an extra render cycle on component mount without changing any behavior.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/app/(home)/login/LocalLoginForm.tsx

Need help? Join our Discord

Analyze latest changes

…nt (MODSetter#941)

AUTH_TYPE is a static module-level import that never changes, so storing
it in React state via useEffect on mount is unnecessary and causes an
extra render cycle. Replace with a direct constant assignment.

Closes MODSetter#941
@vercel
Copy link

vercel bot commented Mar 25, 2026

Someone is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on a474c46..464d998

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (1)

surfsense_web/app/(home)/login/LocalLoginForm.tsx

@MODSetter
Copy link
Owner

@tysoncung, please raise this PR on the "dev" branch.

@MODSetter MODSetter closed this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove unnecessary useEffect + useState for AUTH_TYPE constant in login form

2 participants