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

Update useDynamicFontSizing.ts #7785

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update useDynamicFontSizing.ts #7785

wants to merge 1 commit into from

Conversation

mdqst
Copy link

@mdqst mdqst commented Oct 23, 2024

Explanation

useRef with null initial value: Initialized textInputElementWidthRef with null to ensure it's easier to check if the layout has been set.

Simplified conditionals: Removed unnecessary checks for textInputElementWidthRef after setting the width.

Early return in onSetFontSize: Added an early return if the layout width hasn't been set to avoid unnecessary calculations.

Cleaner scaling logic: Simplified the math operations in getStringWidth and onSetFontSize for clarity and performance.

These changes make the code easier to read and slightly more efficient.

These changes make the code easier to read and slightly more efficient.
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