calintamas / react-native-toast-message

Animated toast message component for React Native
MIT License
1.62k stars 255 forks source link

Toast config not applied for InfoToast component #462

Closed SocDario closed 1 year ago

SocDario commented 1 year ago

I have created toastConfig const in App.tsx like this:

const toastConfig = {
    success: (props: BaseToastProps) => (
      <BaseToast
        {...props}
        style={{height: 50}}
        text1Style={{
          color: Color.textPrimary,
          fontFamily: 'Oxygen-Regular',
        }}
        text2Style={{
          color: Color.primary,
          fontFamily: 'Oxygen-Regular',
        }}
        text2NumberOfLines={2}
        text1NumberOfLines={2}
      />
    ),

    error: (props: BaseToastProps) => (
      <ErrorToast
        {...props}
        style={{borderLeftColor: 'pink', height: 50}}
        text1Style={{
          color: Color.textPrimary,
          fontFamily: 'Oxygen-Regular',
        }}
        text2Style={{
          color: Color.textPrimary,
          fontFamily: 'Oxygen-Regular',
        }}
        text2NumberOfLines={2}
        text1NumberOfLines={2}
      />
    ),

    info: (props: BaseToastProps) => (
      <InfoToast
        {...props}
        text1Style={{
          color: Color.textPrimary,
          fontFamily: 'Oxygen-Regular',
        }}
        text2Style={{
          color: Color.primary,
          fontFamily: 'Oxygen-Regular',
        }}
        text2NumberOfLines={2}
        text1NumberOfLines={2}
      />
    ),
  };
  <ApolloProvider client={client}>
        <RootNavigator />
        <Toast config={toastConfig} />
  </ApolloProvider>

I have create hook for showing Toast inside my component, but hook is using i18n translation hook for text1 props.. expected behaviour is to show text1 into 2 lines without '...' tail. I have tested it without translation but textStyles and numberOfLines is not applied as it should be..After I removed defaultValue numberOflines=1 from lib code it works, but that is not solution ...

snx-mfallon commented 1 year ago

what was your solution?

SocDario commented 1 year ago

@snx-mfallon I have made mistake in my code. Actually Toasts were working fine, but I initialised Toast once again for my Modal component and didn't pass specified configuration into newly initialised Toast.