私はReactJS(Mastering React)を学ぶ例を取り上げています。例を作り直している間、私はいくつかの声明で無意味であり、助けに感謝します。ReactJSのthis.method.bind(null、...)について理解していますか?
フィドル:Composing Components
まず
...
//Why are we passing null in update.bind(...)?
//Is null here equivalent to 'this'?
<TextBox label='First Name' update={this.update.bind(null,'firstName')}></TextBox>
...
セカンド
Updateメソッドは、しかし、それが呼び出されたときに、キーと値(以下メソッド定義)
...
update: function(key, value) {
var newState = {};
newState[key] = value;
this.setState(newState);
//this.setState({[k]:v});
},
...
を期待単一のパラメータで、正しいキーは、righで更新されます。 t値。
//Aren't we supposed to pass two parameters?
this.props.update(this.refs.newText.value);
うわー!すばらしい簡単な例。 – Bala