UNPKG

vexio-font-static

Version:

Disable font scaling in React Native for Text and TextInput components.

16 lines (11 loc) 561 B
import { Text, TextInput } from 'react-native'; export const disableFontScaling = () => { // Cast to any to avoid TypeScript errors (Text as any).defaultProps = (Text as any).defaultProps || {}; (Text as any).defaultProps.allowFontScaling = false; (TextInput as any).defaultProps = (TextInput as any).defaultProps || {}; (TextInput as any).defaultProps.allowFontScaling = false; console.log('vexio-font-static: Font scaling disabled globally'); }; // Immediately apply the font scaling disable when the package is imported disableFontScaling();