How to stop scaling the font size of snackbar in React Native Application when the device font size is scaling up in Android

234 Views Asked by At

I have used React native snackbar to display backend response in my application. If I increase the device font size of the font size of snackbar message also increasing. I want to fixed the font size of snackbar text. Here is my code.

import Snackbar from 'react-native-snackbar';

webServiceHelper.requestResetPassword(this.state.username, this.state.selectedLanguage)
  .then(response => {
     if (response.error == false) {
        this.setState({
        isLoading: false
     }, () => {
        setTimeout(() => {
          Snackbar.show({
            title: 'Incorrect Credentials',
            duration: Snackbar.LENGTH_INDEFINITE,
            backgroundColor: 'red',
            action: {
              title: 'Please check again',
              onPress: () => this.props.navigation.navigate('Login'),
              color: 'white',
            },
          })
         }, 1000);
}

I used the below code to fixed the font size of <Text> tags. But it's not working for snackbar.

if (Text.defaultProps == null) Text.defaultProps = {};
Text.defaultProps.allowFontScaling = false;

Are there any suggestions to solve this issue.

0

There are 0 best solutions below