下記コードでは、「TypeError: Cannot read property ‘props’ of undefined」となります。
1 2 3 4 5 6 7 8 9 | handle(){ console.log( this .props.xxxx); //エラーが起きる } render() { return (<button onclick={ this .handle}>Click!<button> ); } } |
関数の呼び出し方を変えることで、Reactのオブジェクト(props)にアクセスできるようになります。
1 2 3 4 5 6 7 8 9 | handle(e){ console.log( this .props.xxxx); } render() { return (<button onclick={(e)= this .handle(e)}>Click!<button> ); } } |

アロー関数を使用すると、thisをバインドしなくてもつかえるということのようです。
アロー関数と関数の違いとthisの評価のされ方