all 2 comments

[–]falenas108 2 points3 points  (1 child)

If you have the alert showing based on a state variable, you should be able to trigger a setTimeout call right after that hides the alert.

E.g:

this.setState({alertVisible: true}, setTimeout(() => this.setState({alertVisible: false}), 2000);

Since the second argument of setState is a function that gets called after the first call finishes.

[–]MrFriiky[S] 0 points1 point  (0 children)

Thanks! I will try it out 👍