0
プロパティ非アクティブ関数を使用せずに、非同期関数をbabelとバインドしようとしています。 (私はテストをしています)。私がバインドする必要があるのは、onClick
に追加されたためにthis
が失われるためです。コンストラクタでの非同期関数のバインド
以下のようにeditEntry
で問題なく動作します。非同期ではありません。しかし、私はdeleteEntry
にしようとすると、エラーが発生します。
TypeError: _this.saveEntry is undefined
これは私のクラスである:
class RowActions extends Component {
constructor(props) {
super(props);
console.warn('binding functions');
this.editEntry = this.editEntry.bind(this);
this.saveEntry = this.saveEntry.bind(this);
console.warn('binding functions done');
}
editEntry(e) {
let { blah } = this.props;
e.preventDefault();
}
async saveEdit(e) {
let { blah } = this.props;
e.preventDefault();
}
render() {
let { blah } = this.props;
}
}
私はこれは笑っている – Noitidart