コールバック内で、コンポーネントに渡された小道具を取得したいと思いますが、this.props
を取得できません。this
はそこに定義されていません。ここでReactJSアクセス "this"コールバック
は簡単な例です:
var MyComponent = React.createClass({
options:{
componentFunction: function(c) {
console.log(this.props.myProp); //this references to the options here, not the component itself
}
},
render: function() {
return (
<OtherComponent options={ this.options } />
);
}
});
そして、私は小道具をこのように渡します
<MyComponent myProp={"x"};
は、 おかげで任意のヘルプをお願い申し上げます。
私はES6の構文に移行することを強くお勧めします。矢印の機能では問題ありません。 –
アドバイスありがとう、私の次のプロジェクトのためにやってくれるでしょう! – Surreal