Skip to content

Instantly share code, notes, and snippets.

@kenmori
Created February 18, 2017 11:19
Show Gist options
  • Save kenmori/579dc1a4ce07def65084c014024b0c79 to your computer and use it in GitHub Desktop.
Save kenmori/579dc1a4ce07def65084c014024b0c79 to your computer and use it in GitHub Desktop.
【flowtype/React/Class】これ。how to fix 「Covariant property `[fn]` incompatible with contravariant use in ``` assignment of property `[fn]`」
////error
this._increment = this._increment.bind(this);
^^^^^^^^^^ property `_increment`. Covariant property `_increment` incompatible with contravariant use in
27: this._increment = this._increment.bind(this);
^^^^^^^^^^^^^^^ assignment of property `_increment`
/////// code ////////
constructor(props: Props){
super(props);
this.state = {
value : this.props.value
}
this._increment = this._increment.bind(this);////flowtype Error
this._decrement = this._decrement.bind(this);////flowtype Error
};
_increment (e:any) {
this.setState({
value: this.state.value + 1
})
}
_decrement (e:any) {
this.setState({
value: this.state.value -1
})
}
/////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment