Skip to content
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

fix(Buttons): avoid warnings related to change in order of react hooks #1229

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

marcoskolodny
Copy link
Collaborator

@marcoskolodny marcoskolodny commented Aug 29, 2024

If loadingText was empty and then it's changed to a non-empty string, the browser will complain because of a change in the order of hooks.

This happens because the TextContentRenderer function calls useTheme(). The issue is that one of the calls to TextContentRenderer was conditional: it was called only when loadingText is truthy. This causes the hook to be called more times if loadingText was falsy and suddenly changes to a truthy value.

This issue was causing one of the unit tests from webapp to fail. After applying this fix, all of them pass:

image

})}
</Box>
) : null}
{loadingText ? <Box paddingLeft={8}>{loadingButtonElement}</Box> : null}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line was causing the issue that I explain in the PR description

Copy link

Size stats

master this branch diff
Total JS 12.1 MB 12.1 MB -372 B
JS without icons 2.03 MB 2.03 MB -372 B
Lib overhead 77.1 kB 77.1 kB 0 B
Lib overhead (gzip) 18.9 kB 18.9 kB 0 B

Copy link

Accessibility report
✔️ No issues found

ℹ️ You can run this locally by executing yarn audit-accessibility.

Copy link

Deploy preview for mistica-web ready!

✅ Preview
https://mistica-jur8fd99b-flows-projects-65bb050e.vercel.app

Built with commit e0966f5.
This pull request is being automatically deployed with vercel-action

@marcoskolodny marcoskolodny added this pull request to the merge queue Aug 29, 2024
Merged via the queue into master with commit 2dbc411 Aug 29, 2024
11 checks passed
@marcoskolodny marcoskolodny deleted the fix-button-hook-warnings branch August 29, 2024 13:18
tuentisre pushed a commit that referenced this pull request Sep 3, 2024
# [15.19.0](v15.18.0...v15.19.0) (2024-09-03)

### Bug Fixes

* **Buttons:** avoid warnings related to change in order of react hooks ([#1229](#1229)) ([2dbc411](2dbc411))
* **i18n): Revert "feat(i18n:** improve texts sizes" because it is breaking ([#1226](#1226)) ([79eb4a4](79eb4a4))
* **Logo:** fix webpackChunkName magic comments ([#1214](#1214)) ([3d1f098](3d1f098))
* **Vivinho char:** vivinho char in headings being read as a separated heading ([#1209](#1209)) ([f0f5fb0](f0f5fb0))

### Features

* **Buttons:** refactor code and fix spacing bug in loading buttonLink ([#1212](#1212)) ([640e429](640e429))
* **i18n:** improve texts sizes ([#1204](#1204)) ([0345e7c](0345e7c))
* **Logo:** Refactor logo to improve bundle size and loading times ([#1210](#1210)) ([15b77cb](15b77cb))
* **NavigationBar, FunnelNavigationBar, MainNavigationBar:** add alternative variant ([#1200](#1200)) ([eef87ec](eef87ec))
@tuentisre
Copy link
Collaborator

🎉 This PR is included in version 15.19.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants