站内导读

中文

定位:React 是用于构建用户界面的 JavaScript 库,由 Meta 与开源社区维护,适合需要随数据变化更新交互界面的前端项目。

核心能力

  • 声明式渲染:你为每个状态描述视图,数据变化时 React 只更新并渲染对应的组件。
  • 组件化:组件自行管理 state 并组合成复杂界面,逻辑写在 JavaScript 里而不是模板中。
  • state 保留在组件层而非 DOM,可在应用中传递复杂数据,不必重写现有技术栈。
  • 借助 Node 做服务端渲染,通过 React Native 构建移动应用,支持按需渐进引入。

适用人群:具备 JavaScript 基础的前端开发者,用于把 React 加入现有项目或新建应用;服务端渲染需 Node 环境。

注意:README 仅涉及安装、文档与贡献,未列出性能或版本限制。

README · 详细文档

来源 · 查看原文

React · 0 1 2 3 4

React is a JavaScript library for building user interfaces.

  • Declarative: React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable, simpler to understand, and easier to debug.
  • Component-Based: Build encapsulated components that manage their own state, then compose them to make complex UIs. Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep the state out of the DOM.
  • Learn Once, Write Anywhere: We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code. React can also render on the server using Node and power mobile apps using React Native.

Learn how to use React in your project.

Installation

React has been designed for gradual adoption from the start, and you can use as little or as much React as you need:

Documentation

You can find the React documentation on the website.

Check out the Getting Started page for a quick overview.

The documentation is divided into several sections:

You can improve it by sending pull requests to this repository.

Examples

We have several examples on the website. Here is the first one to get you started:

import { createRoot } from 'react-dom/client';

function HelloMessage({ name }) {
  return <div>Hello {name}</div>;
}

const root = createRoot(document.getElementById('container'));
root.render(<HelloMessage name="Taylor" />);

This example will render "Hello Taylor" into a container on the page.

You'll notice that we used an HTML-like syntax; we call it JSX. JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML.

Contributing

The main purpose of this repository is to continue evolving React core, making it faster and easier to use. Development of React happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving React.

Code of Conduct

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to React.

Good First Issues

To help you get your feet wet and get you familiar with our contribution process, we have a list of good first issues that contain bugs that have a relatively limited scope. This is a great place to get started.

License

React is MIT licensed.

相关项目 · GitHub 热门

查看全部「GitHub 热门」项目 →