I recently upgraded to 0.14.4 and I updated all my snackbars to use the new prop open. However I am still getting the following warning
Warning: Failed propType: Required prop 'open' was not specified in 'Snackbar'. Check the render method of 'PageManagerFormDetailed'.
here is my Snackback from that component
<Snackbar
open={this.state.showSnackbar}
message="Changes Saved"
onRequestClose={::this.closeSnackBar}
autoHideDuration={2000}
/>
it works correctly, but am still getting a warning message.
Your example code throws an error here due to ::this.
That is ES6 syntax equal to this.closeSnackBar.bind(this)
I'm not sure we can do anything about it. That's React how is throwing this warning based on our PropType and the property you are providing.
Why wouldn't you fix it? You have a required prop 'open' and I specified it. Is there something wrong with my code?
Why wouldn't you fix it?
Sorry, the tag was remove 6 hours ago.
Is there something wrong with my code?
Is removing this component removing the warning?
yes if i remove the above code, the warning is no longer presented.
@hamiltondanielb Well, I can't help. That doesn't make any sense to me. If you find the solution, I'm curious to know. Thanks
@hamiltondanielb Any change this.state.showSnackbar can ever have the value of undefined?
I had this issue in my project. The cause was that the value of the open attribute was undefined, because I was using a key in this.state that did not exist. After changing the value of the open attribute to the right key, the error went away.
That is ES6 syntax equal to this.closeSnackBar.bind(this)
No, it's ES7, which is why it throws an error here when testing. However I think the cause of your issue has been established. Feel free to reopen if not, and you have something we can use to diagnose.
I fund solution, just init your state.open props into constructor, its work fine for me.
constructor(props){
super(props);
this.state = {
open: false,
};
}
I did this
...
Most helpful comment
I did this
open={open || false}
...