-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Fix wallet hydration issue on next.js #1117
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/wallet/components/Wallet.tsx
Outdated
const [isClient, setIsClient] = useState(false); | ||
|
||
useEffect(() => { | ||
setIsClient(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to solve this for 2~3 components at the same time.
As I see this being an issue for Identity components as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tested Identity
in my app and it didn't seem to be an issue
@@ -43,6 +43,17 @@ const WalletContent = ({ children }: WalletReact) => { | |||
}; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure there is a changeset for this PR as well.
@@ -26,6 +27,13 @@ export function Swap({ | |||
}; | |||
}, [children]); | |||
|
|||
const isMounted = useIsMounted(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice
@@ -0,0 +1,9 @@ | |||
import { useEffect, useState } from 'react'; | |||
|
|||
export function useIsMounted() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this!!!!
What changed? Why?
Following up on #1077
User reported receiving a hydration warning from their next.js app when integrating the
Wallet
component which is likely because theWallet
component depends on client-specific data. The user is using pages routing and components in the pages/ directory are considered to be client-side by default, which, in this case, results in a hydration error.I am resolving this issue by returning
null
inWallet
component until the component mounts.Notes to reviewers
How has it been tested?