Answer the question
In order to leave comments, you need to log in
How to show notification in React for 3 seconds and hide?
The usual question is, I do a program like tinder and when you put a like, you just need to show a notification or animation for a few seconds that the like has been made. How can this be implemented?
Answer the question
In order to leave comments, you need to log in
to trigger a notification, you add a checkbox in the state of the type in the parent component:
this.state = {
isAlertVisible: false
}
// ...
<Alert isVisible={this.state.isAlertVisible} />
handleClick = event => {
// ...
this.setState({isAlertVisible: true}, () => {
setTimeout(
() => {this.setState({isAlertVisible: false})},
3000
)
})
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question