interface icon indicating copy to clipboard operation
interface copied to clipboard

Update useDynamicFontSizing.ts

Open mdqst opened this issue 1 year ago • 0 comments

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.

mdqst avatar Oct 23 '24 08:10 mdqst