Skip to content

Fix ESLint errors: remove setState-in-effect and unused parameters#2

Merged
Kinin-Code-Offical merged 3 commits intomainfrom
copilot/fix-eslint-errors-warnings
Jan 31, 2026
Merged

Fix ESLint errors: remove setState-in-effect and unused parameters#2
Kinin-Code-Offical merged 3 commits intomainfrom
copilot/fix-eslint-errors-warnings

Conversation

Copy link
Contributor

Copilot AI commented Jan 31, 2026

Resolves 1 error and 3 warnings flagged by ESLint related to React hooks and unused variables.

Changes

HomeClient.tsx - Eliminated cascading render from setState-in-effect

  • Moved virtualKeysOpen state declaration before scroll callback to enable direct access
  • Invoked setVirtualKeysOpen(false) directly in scroll handler when dockKeysVisible transitions to false
  • Removed problematic useEffect that was calling setState synchronously
// Before: setState in useEffect triggers cascading renders
useEffect(() => {
  if (!dockKeysVisible && virtualKeysOpen) {
    setVirtualKeysOpen(false);
  }
}, [dockKeysVisible, virtualKeysOpen]);

// After: setState in event handler
const scrollProgressRef = useSmoothScrollProgress(heroRef, (value) => {
  // ... scroll logic ...
  if (dockKeysVisibleRef.current !== nextDockKeysVisible) {
    setDockKeysVisible(nextDockKeysVisible);
    if (!nextDockKeysVisible) {
      setVirtualKeysOpen(false);  // Direct call in handler
    }
  }
});

HeroScene.tsx - Cleaned up unused parameters and missing dependencies

  • Removed unused isMobile parameter from ComputerModel function and call site
  • Removed unused onFocusAction parameter from SceneContent function
  • Added shadowsEnabled to useLayoutEffect dependency array

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/kinin-code/kinin-code/node_modules/.bin/next build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Fix ESLint Errors and Warnings

Please fix the following linting issues found by ESLint:

Error in src/components/HomeClient.tsx (Line 661)

Issue: Calling setState synchronously within a useEffect can trigger cascading renders

Current code (lines 659-663):

useEffect(() => {
  if (!dockKeysVisible && virtualKeysOpen) {
    setVirtualKeysOpen(false);
  }
}, [dockKeysVisible, virtualKeysOpen]);

Solution: Refactor to derive state instead of updating it synchronously in an effect. The virtualKeysOpen state should automatically close when dockKeysVisible is false, so we should derive the effective state rather than setting it.

Replace the useEffect with derived state or restructure the logic to avoid the synchronous setState call within the effect.

Warnings in src/components/hero/HeroScene.tsx

Issue 1 (Line 295): Unused variable isMobile

  • Remove the unused isMobile variable declaration

Issue 2 (Line 780): Missing dependency shadowsEnabled in useLayoutEffect hook

  • Add shadowsEnabled to the dependency array of the useLayoutEffect hook at line 780

Issue 3 (Line 1116): Unused variable onFocusAction

  • Remove the unused onFocusAction parameter from the function signature

Files to modify:

  1. src/components/HomeClient.tsx - Fix the setState-in-effect error
  2. src/components/hero/HeroScene.tsx - Fix the three warnings

Expected outcome:

  • All ESLint errors and warnings should be resolved
  • No functional changes to the application behavior
  • Code should pass npm run lint without any issues

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 31, 2026 06:09
- HomeClient.tsx: Replaced useEffect setState with derived state
- HeroScene.tsx: Removed unused isMobile parameter
- HeroScene.tsx: Added shadowsEnabled to useLayoutEffect dependencies
- HeroScene.tsx: Removed unused onFocusAction parameter

Co-authored-by: Kinin-Code-Offical <125186556+Kinin-Code-Offical@users.noreply.github.com>
Moved virtualKeysOpen state declaration before scroll callback and clear it directly in the event handler when dock becomes hidden, preserving original behavior while avoiding cascading renders

Co-authored-by: Kinin-Code-Offical <125186556+Kinin-Code-Offical@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ESLint errors and warnings in HomeClient and HeroScene Fix ESLint errors: remove setState-in-effect and unused parameters Jan 31, 2026
@Kinin-Code-Offical Kinin-Code-Offical marked this pull request as ready for review January 31, 2026 06:23
Copilot AI review requested due to automatic review settings January 31, 2026 06:23
@Kinin-Code-Offical Kinin-Code-Offical merged commit f16315b into main Jan 31, 2026
1 check passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes ESLint hook/unused-parameter findings by removing unused component parameters, correcting a hook dependency list, and restructuring HomeClient to avoid setState inside a useEffect.

Changes:

  • HomeClient.tsx: Removes the useEffect that synchronously closed virtualKeysOpen and instead closes it from the scroll handler when the dock transitions hidden.
  • HeroScene.tsx: Removes unused parameters (isMobile, onFocusAction) and adds shadowsEnabled to a useLayoutEffect dependency array.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/components/HomeClient.tsx Eliminates setState-in-useEffect by closing virtual keys from the scroll-driven dock visibility transition.
src/components/hero/HeroScene.tsx Removes unused parameters and updates hook dependencies to satisfy ESLint rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

scene,
setPlaneColor,
usePhoneRig,
shadowsEnabled,
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

shadowsEnabled was added to this useLayoutEffect dependency list, but the effect does a full scene.traverse(...) and also calls onDebugAction(...) every time it runs. Since shadowsEnabled toggles with interactionActive/enhancedLighting, this can cause repeated expensive traversals and repeated debug callbacks (in HomeClient, onDebugAction updates modelReadyAt, which can delay the boot timing). Consider removing all shadowsEnabled usage from this layout effect (it’s only used to set castShadow/receiveShadow) and rely on the existing useEffect([scene, shadowsEnabled]) below to apply shadow flags, so shadow toggles don’t retrigger the heavy layout pass.

Suggested change
shadowsEnabled,

Copilot uses AI. Check for mistakes.
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.

3 participants