LoginSignup
1
2

More than 5 years have passed since last update.

JSX記法

Posted at

JSX記法メモ

index.js
ReactDOM.render(
  <div>Hello World</div>, // 末尾のカンマがないと動かない
  document.getElementById('root')
);

classの付け方

index.js
ReactDOM.render(
  <div className="hello">Hello World</div>, // classは予約語なのでclassNameを使う
  document.getElementById('root')
);

イベントの付け方

index.js
ReactDOM.render(
  <div onClick={関数名}>Hello World</div>, // 関数名を波括弧で囲う
  document.getElementById('root')
);
1
2
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
1
2