Skip to content

Pass Toast values to onShow method #572

@AdamGerthel

Description

@AdamGerthel

Is your feature request related to a problem? Please describe.
I want to implement announceForAccessibility for Toasts since they're inherently not great for screenreader (i.e. TalkBack/VoiceOver). Because Toasts are global, I'd like to implement this globally, rather than having to rely on passing it every time I call on Toast.show.

Describe the solution you'd like
I would like onShow to provide me with the values the toast has, so that I can do something like:

<Toast onShow={({ text1, text2 }) => AccessibilityInfo.announceForAccessibility(text1 + '\n' +  text2)} />

So my suggestion is that onShow is changed to:

(props: {
  type: string,
  text1: string,
  text2: string?
}) => void

and of course, this could probably be applied to onHide and onPress as well.

Describe alternatives you've considered
I could pass an onHide function on every Toast.show but I would like to implement this globally since all toasts will need it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions