LoginSignup
0
0

More than 1 year has passed since last update.

React: Props の使い方

Last updated at Posted at 2022-06-27

こちらを参考にしました。
React Props

コマンドのインストール

sudo npm install -g create-react-app
sudo npm install -g yarn

使ったバージョン

$ node --version
v18.4.0
$ yarn --version
1.22.19
$ npx create-react-app --version
5.0.1

プロジェクトの作成

create-react-app re01
cd re01
yarn start

src/App.js を次で置き換えます。

src/App.js
import logo from './logo.svg';
import './App.css';

function Car(props) {
  return <h2>I am a { props.brand }!</h2>;
}

function App() {
  return (
    <div className="App">
      <header className="App-header">
	<p>Hello World!</p>
	<Car brand="Honda" />
	<Car brand="BMW" />
	<blockquote>
	<p>Jun/28/2022</p>
	</blockquote>
      </header>
    </div>
  );
}

export default App;

ブラウザーで、 http://localhost:3000/ にアクセス
image.png

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