- Core Ideas
- Some Tips
- MAIN CONCEPTS
- ADVANCED GUIDES
- hooks
- API REFERENCE
- React Testing
- TypeScript with React
- Q/A
- We typically want to perform our effects after React has updated the DOM => put side effects into
componentDidMount
andcomponentDidUpdate
oruseEffect
.
In stateless component,
return()
runs beforeuseEffect()
- Props are Read-Only
flowchart LR
Component -->|return| e("Element Object") -->|describe| ht("HTML Tag")
Eg returned element (object) === Virtual DOM:
{
type: "main", // string element to an HTML tag (DOM element) || Component
key: null,
ref: null, // reference to a real DOM node
"$$typeof": Symbol(react.element),
props: {
children: {
}
}
}
GO TO MAIN CONCEPTS
- State and Lifecycle
- Handling Events
- Conditional Rendering
- Lists and Keys
- Forms
- Lifting State Up
- Composition vs Inheritance
- Thinking in React
GO TO ADVANCED GUIDES
- Typechecking With PropTypes
- JSX In Depth
- Code-Splitting
- Context
- Refs and the DOM
- Uncontrolled Components
- Higher-Order Components
- Refs and the DOM (before Callback Refs)
- Forwarding Refs
GO TO API REFERENCE
GO TO hooks
A:
- The
state
changes (including global state) - There comes new
props
[4]
FC: 每次重新執行函數時,都是傳入獨立的 props,並且 state 也是獨立
CC: based on OOP,may have old props or state
- 應避免將由 parent component 使用(interpret) 的
props
,forward 至 child component