[Tutorial] Potentially confusing explanation of how a component rendering is triggered
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 11.8k
- 派生
- 7.9k
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 11
描述
I'm new to React and when learning, I first went through the tutorial and then went through the docs. In the tutorial I didn't quite understand why we absolutely have to use the setState() method. But when going through the Using State Correctly and then the API docs for setState() I understood why. Then I went back to the tutorial to see why I couldn't get this from the tutorial. State is introduced in the Making an Interactive Component section.
I think it'd be better if it's explicitly mentioned here that state changes are what causes components to be re-rendered and hence, one shouldn't attempt to modify state directly. The following part particularly is what gave the wrong impression I think. I took this to mean that it's events such as onClick that triggers a rendering.
By calling
this.setStatefrom anonClickhandler in the Square’srendermethod, we tell React to re-render that Square whenever its<button>is clicked.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
查看教程中的“Making an Interactive Component”部分,以及链接的“Using State Correctly”和“setState() API”文档。重点关注引用的解释,并验证修订后的文本是否清楚地区分了点击事件和状态变化。当新手理解 setState() 为什么会触发渲染,以及为什么不应直接修改状态时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, react
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 1/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 55/100