Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onHIide feature for toast does not work, if i pass code to execute for onHide callback as arguement #484

Open
martsa opened this issue Aug 28, 2023 · 1 comment

Comments

@martsa
Copy link

martsa commented Aug 28, 2023

Describe the bug
when ever i pass a code as argument for onHide callback , code get executed before even showing toast message. But when i pass a static code withing onHide callback it does works.

Steps to reproduce
Steps to reproduce the behavior:

function showToast(value1,value2,value3,value4){
Toast.show({
text1:value1,
text2:value2,
position:'top',
type:value3,
onHide:()=>{value4},
})
}

when i passed below argument to showToast function , code props.onPickScreen('Bar') passed as argument execute before even showing toast message. And i never get to see toast message. Actually this code should be fired once toast message is hide.

showToast("Reservation process failed "," please rescan it ","error", props.onPickScreen('Bar'))

Expected behavior
Actually code should be executed once toast message is hide automatically. instead of passing code as argument and adding statiic code for onHide callback , it does work.
Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [iOS, Android,]
@vozaldi
Copy link

vozaldi commented Sep 21, 2023

The error is not related to this plugin. It's because you called the onPickScreen method directly.

showToast("Reservation process failed "," please rescan it ","error", props.onPickScreen('Bar'))
//                                                                           ^ This function is executed immediately

You should make value4 parameter as callback:

function showToast(value1,value2,value3,value4){
  Toast.show({
    text1:value1,
    text2:value2,
    position:'top',
    type:value3,
    onHide: value4,
  })
}

And you should pass a function for value4 when calling the function:

showToast("Reservation process failed "," please rescan it ","error", () => props.onPickScreen('Bar'))
//                                                                       ^ This one is a callback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants