schiehll / react-alert

alerts for React
MIT License
607 stars 99 forks source link

render blank when setState call #69

Closed frankLife closed 6 years ago

frankLife commented 6 years ago

I found the code in Provider.js

 if (this.state.isClient && !this.alertRootElement) {
      this.alertRootElement = document.createElement('div')
      document.body.appendChild(this.alertRootElement)
    } else {
      return null
    }

I use the react-alert like example

render(){
  return (
      <AlertProvider template={AlertTemplate} {...options}>
        <App />
      </AlertProvider>
    )
}

when I setState the state of App and the render function start to run . The logic of alert provider would return null and page render blank.

I update the componentWillUpdate logic same with the componentWillUnmount of the provider. It seems works right.

What should I do for this ? Is there anything I mistake ? @schiehll ❓

schiehll commented 6 years ago

Should be fixed after #70.

Be sure to put the Provider in your root component.

If you still get the error after the update, feel free to reopen!