Closed poinch closed 9 months ago
For anyone who is facing the same problem i fixed by creating something like this:
import { Text as RNText } from 'react-native';
import { Text, Input } from '@ui-kitten/components';
interface RNTextWithDefaultProps extends RNText {
defaultProps?: { allowFontScaling?: boolean };
}
interface TextWithDefaultProps extends Text {
defaultProps?: { allowFontScaling?: boolean };
}
interface InputTextWithDefaultProps extends Input {
defaultProps?: { allowFontScaling?: boolean };
}
export const changeComponentsDefaultProps = () => {
(RNText as unknown as RNTextWithDefaultProps).defaultProps =
(RNText as unknown as RNTextWithDefaultProps).defaultProps || {};
(RNText as unknown as RNTextWithDefaultProps).defaultProps!.allowFontScaling = false;
(Text as unknown as TextWithDefaultProps).defaultProps =
(Text as unknown as TextWithDefaultProps).defaultProps || {};
(Text as unknown as TextWithDefaultProps).defaultProps!.allowFontScaling = false;
(Input as unknown as InputTextWithDefaultProps).defaultProps =
(Input as unknown as InputTextWithDefaultProps).defaultProps || {};
(Input as unknown as InputTextWithDefaultProps).defaultProps!.allowFontScaling = false;
};
Basically i have created a function where i'm changing the default props of the React Native Text (because i'm using it, otherwise you can just avoid it), and the Text and the Input of UI Kitten. Here i'm on a typescript project that's why i'm in need of interfaces. Just call the function as soon the app starts.
💬 Question
UI Kitten and Eva version
I need to do not allowFontScaling across the entire app so i was wondering if there's a way to set allowFontScaling to false using the custom-mapping. I'm asking because i've already used thounds of times the Text component and it will be a pain to create a custom component at this point.