calintamas / react-native-toast-message

Animated toast message component for React Native
MIT License
1.73k stars 265 forks source link

Get visibility time inside Toast config for building Custom Layouts #548

Open AlistairM13 opened 5 months ago

AlistairM13 commented 5 months ago

Is your feature request related to a problem? Please describe. I wanted to build a custom toast that runs an animation showing its visibility time, sort of like toastify but I could not get hold of visiblityTime inside the config.

Describe the solution you'd like Something like this:

export const toastConfig = {
  timed: (props) => {
      const { visibilityTime, text1, type } = props
      ...
  },
}

Describe alternatives you've considered Current workaround I am using:

// Config
export const toastConfig = {
  timed: (props) => {
      const { visibilityTime } = props.props // passed via custom props
      ...
  },
}
// Call
Toast.show({ 
  type: "timed",
  visibilityTime: 10000,
  props: { 
    visibilityTime: 10000 
  },
  text1: "Something here"
})

While it does work, would love to know if there is a better way to do this.