Skip to content

Fix hydration error in Button component - #4

Open
izaz-ahamed-mallick wants to merge 1 commit into
acharnabin:masterfrom
izaz-ahamed-mallick:t3Open
Open

Fix hydration error in Button component#4
izaz-ahamed-mallick wants to merge 1 commit into
acharnabin:masterfrom
izaz-ahamed-mallick:t3Open

Conversation

@izaz-ahamed-mallick

Copy link
Copy Markdown

Screenshot 2025-01-13 121302

The error in the console

From the screenshots, the error seems related to a hydration mismatch (as mentioned in the error message). This happens when the content rendered by the server does not match the content rendered by the client, which can lead to issues with React components that are conditionally rendered based on client-specific conditions like window.

Screenshot 2025-01-13 124756

Code Before Changes

The code before your changes might have had some discrepancies between what was server-rendered and client-rendered,.

Screenshot 2025-01-13 124834

Code After Changes

In the code after your change, you introduced the isLoading state with the useEffect hook to sync the loading state with the loading prop. This ensures that the button content (loadingText or children) is rendered consistently both on the server and the client.

Screenshot 2025-01-13 132703
Not Show any hydration error

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