基本まとめ
import React from 'react'; class App extends React.Component { constructor(props) { super(props); this.state = {プロパティ名: 値}; } render() { return ( <div> {/* stateの値を取得するには「this.state.プロパティ名」を入れる*/} <h1>こんにちは、{this.s</h1></div>…
イベントの書き方 ・アロー関数を使って、タグ内に イベント名={() => { 処理 }} と書くことで、指定したタイミングで処理を実行できる。 アロー関数はJavaScriptなので、{}で囲むことを忘れないように 「クリックされた時に処理を実行する」onClickイベント…
配列.lengthとすることで、配列の要素数を取得できる const animals = ["dog", "cat", "sheep", "rabbit", "monkey", "tiger", "bear", "elephant"]; // lengthを用いて配列の要素の数を出力 console.log(animals.length); // lengthを用いて条件式を書き換…
Dockerを使ってサーバーを立ち上げる ローカル環境を使って実施。 変数をタグを入れて表示する ・{}で変数を囲い、変数にhtmlを入れて表示 const contentData = ({data2}) => ({data2}) const ja = "*****Japan!"; return ( <h1>{ja}</h1> ちなみに、最初、「Japan!」…