LoginSignup
2
1

More than 5 years have passed since last update.

c => this.input = c

Posted at

タイトルのコードは、Reactを勉強している時に見かけた文法

<input type="text" placeholder="TODOを入力..." ref={c => this.input = c} />

{c => this.input = c}

なんやねん、この記述!何を意味しとるかさっぱりわからん。

以下の説明を見つけて納得

// functionを使った書き方
function(c) {
  this.input = c;
}

// アロー関数省略なし
(c) => {
  this.input = c;
}

// 引数が1つの場合は()省略可
c => {
  this.input = c;
}

// ブロックが一行の場合こういった書き方もする
c => this.input = c;

はえー、そういうことやったんか!

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1