calintamas / react-native-toast-message

Animated toast message component for React Native
MIT License
1.69k stars 261 forks source link

Custom props do not work #526

Closed mattlewer closed 8 months ago

mattlewer commented 8 months ago

Describe the bug In the docs an example is shown to pass custom props:

Toast.show({
  type: 'tomatoToast',
  // And I can pass any custom props I want
  props: { uuid: 'bba1a7d0-6ab2-4a0a-a76e-ebbe05ae6d70' }
});

This does not appear to be working.

Steps to reproduce I've tried to implement this as such:

export const duplicateAddressToast = () =>
  Toast.show({
    type: 'error',
    text1: localise('DUPLICATE_ADDRESS_TITLE'),
    text2: localise('DUPLICATE_ADDRESS_DESC'),
    position: 'bottom',
    bottomOffset: 100,
    visibilityTime: 40000,
    props: {linkText: 'gdeddedi'},
  });

And have a toast config:

export const toastConfig: ToastConfig = {
  error: (props: any) => (
    <Pressable
      onPress={() => {
        props.hide();
        props.onPress();
      }}
      style={style.container}>
      <Text style={[typography.TextHeadingMedium5, {color: tokens.TextError}]}>
        {props.text1}
      </Text>
      <Text style={[typography.TextBodyReg4, {color: tokens.TextDark800}]}>
        {props.text2 + ' '}
        <Text style={style.linkText}>{props.linkText}hello</Text>
      </Text>
    </Pressable>
  ),
 };

Expected behavior My linkText prop is displayed, at the moment only the 'hello' portion from the sample above is. I have tried clearing the cache, no difference :/

Code sample Given above

Environment (please complete the following information):

mattlewer commented 8 months ago

Fixed by doing props.props.linkText, should probably update the docs to this