Closed husnulhamidiah closed 6 years ago
Yeah the way you did it won't work because this.props.alert.show
doesn't return a react component, but an object.
If you want it to be triggered by other prop you can use the componentWillReceiveProps
method. Something like this:
class Example extends React.Component {
componentWillReceiveProps(nextProps){
if (nextProps.someProp) this.props.alert.show('Hey!')
}
render(){
return <div>Example</div>
}
}
export default withAlert(Example)
Hope it helps!
So far I can use this module run perfectly with example given in readme. But what I want is display this alert based on another props. Here's what I've try :
It gives me this errors, I use create react app.
So, how do I display alert without button?