React

用于构建用户界面的声明式、高效和灵活的 JavaScript 库。「A declarative, efficient, and flexible JavaScript library for building user interfaces.」

Github stars Tracking Chart

React

React 是一个用于构建用户界面的 JavaScript 库。

  • 声明式:React 使得创建交互式 UI 无痛。 为您的应用程序中的每个状态设计简单的视图,当您的数据更改时,React 将有效地更新和渲染正确的组件。 声明式视图使您的代码更可预测,更易于理解,并易于调试。
  • 基于组件:构建管理自己的状态的封装组件,然后组合它们以创建复杂的 UI。 由于组件逻辑是用 JavaScript 而不是模板编写的,因此您可以轻松地通过应用程序传递丰富的数据,并将状态保留在 DOM 之外。
  • 学习一次,随时随地编码:我们不对您的技术栈的其余部分做出假设,因此您可以在 React 中开发新功能,而无需重写现有的代码。 React还可以使用Node在服务器上渲染,并使用 React Native 为移动应用提供动力。

学习如何在你自己的项目中使用 React

安装

React 是为从一开始就逐步采用而设计的,你可以根据你的需要使用很少或很多React。

你可以将 React 作为 CDN 上的 <script> 标签,或者作为 npm 上的 react 包使用。

文档

你可以 在网站上 找到 React 的文档。

查看 入门页面 以获得快速概述。

该文档分为几个部分:

你可以通过向 这个存储库 发送拉动请求来改进它。

实例

我们 在网站上 有几个例子。这里是第一个让你入门的例子。

function HelloMessage({ name }) {
  return <div>Hello {name}</div>;
}
ReactDOM.render(
  <HelloMessage name="Taylor" />,
  document.getElementById('container')
);

这个例子将把 "Hello Taylor" 渲染成页面上的一个容器。

你会注意到我们使用了一种类似 HTML 的语法;我们称之为 JSX。JSX 不是使用 React 的必要条件,但它使代码更易读,而且写起来感觉像在写 HTML。如果你使用 React 作为 <script> 标签,请阅读 本节 关于集成 JSX 的内容;否则,推荐的 JavaScript 工具链 会自动处理。

贡献

这个资源库的主要目的是继续发展 React 核心,使其更快、更容易使用。React的开发是在GitHub上公开进行的,我们非常感谢社区对错误修复和改进的贡献。请阅读以下内容,了解你如何参与改进 React。

Code of Conduct

Facebook 已经采用了一个行为准则,我们希望项目参与者能够遵守。请阅读 全文,以便了解哪些行为会被容忍,哪些行为不会被容忍。

贡献指南

阅读我们的 贡献指南,了解我们的开发过程,如何提出错误修复和改进,以及如何构建和测试你对 React 的修改。

第一个好问题

为了帮助你了解和熟悉我们的贡献过程,我们有一个 良好的第一个问题 的列表,其中包含了范围相对有限的错误。这是一个开始的好地方。

许可证

React 是 MIT 许可的


Overview

Name With Ownerfacebook/react
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 10)
PlatformLinux, Mac, Web browsers, Windows
License:MIT License
Release Count141
Last Release Namev18.2.0 (Posted on 2022-06-14 12:51:27)
First Release Namev0.3.0 (Posted on )
Created At2013-05-24 16:15:54
Pushed At2024-04-14 07:29:47
Last Commit At
Stargazers Count221.4k
Watchers Count6.6k
Fork Count45.2k
Commits Count16.7k
Has Issues Enabled
Issues Count12788
Issue Open Count1074
Pull Requests Count9950
Pull Requests Open Count350
Pull Requests Close Count4579
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

React · GitHub license npm version CircleCI Status PRs Welcome

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 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 own 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:

You can use React as a <script> tag from a CDN, or as a react package on npm.

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:

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

ReactDOM.render(
  <HelloMessage name="Taylor" />,
  document.getElementById('container')
);

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. If you're using React as a <script> tag, read this section on integrating JSX; otherwise, the recommended JavaScript toolchains handle it automatically.

Contributing

The main purpose of this repository is to continue to evolve 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 which have a relatively limited scope. This is a great place to get started.

License

React is MIT licensed.

To the top