生命周期 Lifecycle
Open
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Instantiation
- getDefaultProps
- getInitialState
- componentWillMount
- render
- componentDidMount
componentDidMount 不会在服务端被渲染的过程中调用
setState
- shouldComponentUpdate
- componentWillUpdate
- render
- componentDidUpdate
Mount
- componentWillReceiveProps
- shouldComponentUpdate
- componentWillUpdate
- render
- componentDidUpdate
阻止不必要的
render, 优化性能, 可以 MixinPureRenderMixin
shouldComponentUpdate (nextProps, nextState) {
return this.state.checked === nextState.checked; // return false 则不更新组件
// 确定该组件渲染完后无需再次更新,即这个组件是一个静态组件,那么可以直接return false(优化性能)
// return false
}
反模式, this.props 计算后的值不应该赋给 state, 否则会导致计算后的值永远不会与派生出它的 props 值不同步
static defaultProps = {
data: new Date()
}
static state = {
data: this.props.date - new Date()
}
render () {
return <div>Day:{this.state.day}</div>
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is identified. Start by reading the lifecycle notes and JSX examples in the issue; the issue does not state a specific documentation change or a clear completion condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100