TOP ▲ itcore TOPTIPSreact_js.php  タグ:react.js インストール create-react-app

react.js インストール create-react-app | itcore 2019年

node.js インストール

Windows Power Shell
PS> npm install -g create-react-app
PS> create-react-app my-app
PS> cd my-app
PS> npm start

アプリ実行
http://localhost:3000/

アプリ終了
PS> CTRL+C
バッチ ジョブを終了しますか (Y/N)? y

各種コマンド

npm start
  Starts the development server.
npm run build
  Bundles the app into static files for production.
npm test
  Starts the test runner.
npm run eject
  Removes this tool and copies build dependencies, configuration files
  and scripts into the app directory. If you do this, you can’t go back!

生成されたソース src/App.js

import React from 'react';
import logo from './logo.svg';
import './App.css';

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;

リリース

PS> npm run build
buildディレクトリ配下をWebサーバへアップする。