Improve Solana wallet detection typing and lint cleanliness#3
Improve Solana wallet detection typing and lint cleanliness#3aster2333 wants to merge 6 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| balance: balance, | ||
| nfts: user?.nfts || [] | ||
| } | ||
|
|
||
| setUser(userData) | ||
| updateBalance() | ||
| } else { | ||
| setUser(null) | ||
| setBalance(0) | ||
| } | ||
| }, [connected, publicKey, setUser, setIsWalletConnected]) | ||
| }, [balance, isConnected, publicKey, setIsWalletConnected, setUser, updateBalance, user]) |
There was a problem hiding this comment.
Avoid infinite wallet update loop
The useEffect that syncs wallet state now depends on user and balance but also calls setUser and updateBalance on every run. Once a wallet connects, setUser writes a fresh object to the Zustand store, changing the user reference each render. Because user is in the dependency array, the effect immediately fires again and repeats the same state write and balance refresh indefinitely, resulting in constant re-renders and repeated RPC calls whenever a wallet is connected. The pre-commit version did not include user/balance in the dependencies, so this loop is newly introduced.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68f891b8611c83268ead0db02e062baa