schiehll / react-alert

alerts for React
MIT License
607 stars 99 forks source link

Always ends up in infinite loop #122

Closed adomas000 closed 5 years ago

adomas000 commented 5 years ago
class A extends React.Component {
  componentWillReceiveProps() {
    this.props.alert.show('this ends up creating infinite loop')
  }
  render() {
    this.props.alert.show('this ends up creating infinite loop')
  }
}

I am trying to send error alert when props are incorrect, but for some reason alert.show is triggering re-render and componentsWillReceiveProps method. What approach should I take here, All examples show how to use an alert on Button click, not very useful in real-life scenarios.

besLisbeth commented 5 years ago

Hi @adomas000, please, have a look at #117, it is the same problem there