Telefonica / mistica-web

React components library for Telefonica Design System (Mistica)
https://mistica-web.now.sh
MIT License
51 stars 10 forks source link

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

Closed marcoskolodny closed 1 month ago

marcoskolodny commented 1 month ago

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

github-actions[bot] commented 1 month ago

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
github-actions[bot] commented 1 month ago

Accessibility report ✔️ No issues found

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

github-actions[bot] commented 1 month ago

Deploy preview for mistica-web ready!

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

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

tuentisre commented 1 month ago

:tada: This PR is included in version 15.19.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: