Skip to content

How do I run a function inside the browser after the call to action() returns? #8129

Closed Answered by Erij-Maherzia-BEN-BRAHIM
offchan42 asked this question in Q&A
Discussion options

You must be logged in to vote

hi @off99555 to display the same error message multiple times from the useEffect, you have only to update the array of dependencies this way 👇🏻

const actionData = useActionData<typeof action>()

useEffect(()=>{

		if(actionData){

			if("errorMessage" in actionData){

			displayErrorToast(actionData.errorMessage)			// call your toast function here

			}

}
},[actionData])

or you can this library to handle your toasts 👇🏻
https://github.com/Code-Forge-Net/remix-toast

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@offchan42
Comment options

@offchan42
Comment options

@offchan42
Comment options

@Erij-Maherzia-BEN-BRAHIM
Comment options

Answer selected by offchan42
Comment options

You must be logged in to vote
2 replies
@sergiodxa
Comment options

@gustavopch
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants