# 起步

# Hello world

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Hello React!</title>
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/[email protected]/babel.js"></script>
  </head>

  <body>
    <div id="root"></div>

    <script type="text/babel">
      class App extends React.Component {
        render() {
          return <h1>Hello world!</h1>;
        }
      }
      ReactDOM.render(<App />, document.getElementById("root"));
    </script>
  </body>
</html>

# 脚手架

# 全局安装脚手架
npm install create-react-app -g 
create-react-app react-project
# 使用npx
npx create-react-app react-project

# 依赖

  • react
  • react-dom
  • react-scripts
import React from "react";
import ReactDOM from "react-dom";
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<h1>Hello, world!</h1>);

# 样式

npm install sass --save-dev
import "./styles/index.scss";