interface
interface copied to clipboard
Update useDynamicFontSizing.ts
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.