Closed guludo closed 6 years ago
Hi, there.
react-alert behaves inconsistently when more than one component using the withAlert() HoC. The following link can be checked to reproduce the problem: https://codesandbox.io/s/w6l7pz9j9w
react-alert
withAlert()
I'm also posting part of the source here:
import React, { Component, Fragment } from 'react' import { withAlert } from 'react-alert' const Foo = ({alert}) => (<button onClick={() => { alert.info('Foo') }}>Foo</button>); const FooWithAlert = withAlert(Foo); const Bar = ({ alert }) => (<button onClick={() => { alert.info('Bar') }}>Bar</button>); const BarWithAlert = withAlert(Bar); class Home extends Component { state = { now: Date.now() } render () { return ( <div> <FooWithAlert /> <BarWithAlert /> <br /> <button onClick={() => {this.setState({ now: Date.now() })}}> Render wrapping component </button> </div> ) } } export default Home
If you use one of the buttons Foo or Bar and then click in Render wrapping component, the previous alert(s) will be shown.
Foo
Bar
Render wrapping component
I've fixed the problem and will raise a pull request shortly.
Best regards, Gustavo Sousa
Fixed in #64
Hi, there.
react-alert
behaves inconsistently when more than one component using thewithAlert()
HoC. The following link can be checked to reproduce the problem: https://codesandbox.io/s/w6l7pz9j9wI'm also posting part of the source here:
If you use one of the buttons
Foo
orBar
and then click inRender wrapping component
, the previous alert(s) will be shown.I've fixed the problem and will raise a pull request shortly.
Best regards, Gustavo Sousa