React - Tic Tac Toc
React - State 和生命周期

React - 组件和 props

violet posted @ Jul 17, 2020 01:24:18 AM in 读书笔记 with tags React , 397 阅读

定义组件可以写函数或者创建 class

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

该函数是一个有效的 React 组件,因为它接收唯一带有数据的 “props”(代表属性)对象与并返回一个 React 元素。这类组件被称为“函数组件”,因为它本质上就是 JavaScript 函数。

class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}

上述两个是等价的。

自定义组件必须开头大写。

所有 React 组件都必须像纯函数一样保护它们的 props 不被修改。

  • 无匹配
charlly 说:
Dec 28, 2022 03:52:06 PM

In React, every user interface is created using small, reusable pieces called components. Every React component has two parts: props and state. props are immutable and are passed to the component by the parent component. state is mutable and is managed within the component itself. diamond rings When a component's state changes, the component will re-render itself.

boardmodelpaper.com 说:
Jan 09, 2024 02:29:16 PM

The Board model paper" typically refers to a sample or model question paper that is designed by educational boards or institutions for various exams. These papers serve as practice material for students preparing for exams, providing them with an idea of the question format, difficulty level, and the type of content that may be covered in the actual examination. boardmodelpaper.com Model papers are usually created for specific subjects or courses. They cover a range of topics and chapters that students are expected to have studied during the academic term. Students often use these educational board model papers as an integral part of their exam preparation strategy, helping them familiarize themselves with the exam pattern and refine their understanding of the subject matter.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter