Skip to content

Fixed an infinite loop when selecting desktop icons#97

Open
m417z wants to merge 1 commit intoShizukuIchi:masterfrom
m417z:patch-2
Open

Fixed an infinite loop when selecting desktop icons#97
m417z wants to merge 1 commit intoShizukuIchi:masterfrom
m417z:patch-2

Conversation

@m417z
Copy link
Copy Markdown

@m417z m417z commented Jun 5, 2021

The problem was that a new onIconsSelected function was created on each render, causing the following infinite loop:

  • WinXP() is called.
  • A new onIconsSelected function is passed to <Icons />.
  • useEffect is called inside Icons(), and setSelectedIcons is called.
  • setSelectedIcons triggers a dispatch, causing WinXP() to be called again.

To fix this, I wrapped setSelectedIcons with useCallback. And while at it, I wrapped all other functions.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/shizukuichi/winXP/AwLsNmPBA6QutX2DU9Uxf3jguHPk
✅ Preview: https://winxp-git-fork-m417z-patch-2-shizukuichi.vercel.app

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.

1 participant