Revert "Deploy StepFi-Web to Vercel"#35
Open
EmeditWeb wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@EneGab please work on the build fail
Fix the ESLint error in src/components/layout/Navbar.tsx.
The error is on line 28:
react-hooks/set-state-in-effect
Calling setState synchronously within an effect is not allowed.
The current code:
useEffect(() => {
setMobileOpen(false)
}, [pathname])
Fix by wrapping the setState call in a cleanup or using
a ref to avoid the synchronous setState inside the effect.
The correct pattern is to check if pathname changed
using a ref instead of calling setState inside the effect:
import { useEffect, useRef } from 'react'
const prevPathnameRef = useRef(pathname)
useEffect(() => {
if (prevPathnameRef.current !== pathname) {
prevPathnameRef.current = pathname
setMobileOpen(false)
}
}, [pathname])
OR the simpler approach that also satisfies the linter:
Remove the useEffect entirely and instead close the
setMobileOpen(false)} ... >menu by passing an onClick handler to each nav Link:
This is cleaner because it only closes the menu when
the user actually clicks a link, not on every pathname
change, which is the more correct behavior anyway.
After fixing:
npm run lint 2>&1 | tail -5
npm run build 2>&1 | tail -5
Both must exit 0.
Commit and push to your branch:
git add src/components/layout/Navbar.tsx
git commit -m "fix: remove setState in effect for mobile menu close"
git push origin [branch-name]
Report: lint and build output.