I have this kind of initialisation going on in my React components:
export default class LoginForm extends Component {
state = { // (*)
flash: {
message: null,
style: null
} // initialiser for flash message: show nothing
}
showError(error_message: string) {
this.setState({
flash: {
message: error_message,
style: "danger"
})
}
Unfortunately, flow is treating the initialisation of the flash property of the state object as a type declaration, and in the subsequent setState() it flags the new declaration of the value of the flash property as a type mismatch ("string is incompatible with null").
How can I tell flow what is actually going on here, and thus avoid it reporting an error?
(*) note: I originally erroneously had a : in this line instead of = ... @DanPrince corrected that.