React 快速开始指南 🚀

想要快速上手 React?你来到了正确的页面!以下是一些基础步骤,帮助你快速开始使用 React。

1. 安装 Node.js 和 npm

首先,确保你的开发环境已经安装了 Node.js 和 npm。它们是构建 React 应用所必需的。

2. 创建 React 应用

使用 create-react-app 工具可以快速搭建一个 React 应用。

npx create-react-app my-app
cd my-app

3. 编写组件

React 应用由组件组成。组件是 React 应用中最小的不可分割的单元。

import React from 'react';

function App() {
  return (
    <div>
      <h1>Hello, world!</h1>
    </div>
  );
}

export default App;

4. 运行应用

在你的应用目录下,运行以下命令来启动开发服务器。

npm start

这时,你应该可以在浏览器中看到你的 React 应用了!

5. 扩展阅读

想要更深入地了解 React?以下是一些推荐的学习资源:

React Logo