0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

React 入門 (#1) ~DOM操作とReactライブラリ導入~

Last updated at Posted at 2021-03-14

この記事では、Reactの基礎について学んでいきます。

2021-03-14_12h56_17.png

ソースコードブラウザ表示を中心に進めていきます。
ソースコードには、そのコードが何を表しているのかを**話し口調(下の赤枠)**で書いているので
そこに注目して読むとより理解が深まると思います。

例)
2021-03-14_13h23_51.png

楽しんで学習をすすめていきましょう。

1,JavaScriptを記述してDOMの操作を行ってみます。

基本的なHTMLのソースコードです。
code.png

index.htmlにリンクしているindex.js(JavaScript)です。
code2.png

2,実際に上のソースコードの動きを確認してみましょう。

2021-03-14_12h37_47.gif

とてもシンプルな動きですね。
これが、JavaScript によるDOM操作になります。

3,Reactライブラリの導入

書き換えたindex.htmlのソースコード
code4.png

上のサイトから、追記したソースコードをコピーしてください。
もしくは、こちらをコピーしてください。

index.html
  //追記 ReactライブラリとReactDOMライブラリ
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>

Reactを使うには、
ReactライブラリReactDOMライブラリを使います。
これで、準備完了です。

index.jsファイルに移動して次のコードを記述します。
code5.png

4,ブラウザ表示

index.htmlにはdivタグしかないですが、ちゃんと表示されていますね。
2021-03-14_13h43_54.png

次回は、

今回は、Reactの機能の部分を簡単に紹介しました。
次回は、Reactを学ぶうえで大事なBabelJSXに触れたいと思います。
リンク

0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?