Documentation error in the Render Props - Needs Interpolation
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 11.8k
- 派生
- 7.9k
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 11
描述
Hi Team,
I am trying to give a small correction in the documentation code of React under the topic Render Props.
This isn't such a big issue, but will definitely help newbies and must be addressed.
Under the Render Props concept in React documentation, in one of the examples, where a class component of Cat is created which returns an image, which is positioned absolutely. The position of that image is received through render props.
The received position coordinates are passed to the absolute positioned image. Now the problem is instead of using interpolation and adding units into it, the position coordinates values are directly given in the style object. Surprisingly the Img still moves respectively to the mouse pointer.
But I don't think giving the values without units is the right thing.
So, the below code should be changed from
From:
render() {
const mouse = this.props.mouse;
return (
<img src="/cat.jpg" style={{ position: 'absolute', left: mouse.x, top: mouse.y }} />
);
}
To:
render(){
const mouse = this.props.mouse;
return (
<img src= './imgs/cat.jpg' style={{ left: ${mouse.x}px, top: ${mouse.y}px}} />
)
}
If my understanding is wrong, please correct me.
Much thanks!
Regards,
Hari prasad
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 React 文档的 Render Props 部分开始,检查以图像样式显示鼠标坐标的 Cat 示例。根据周围的文档和 React 的行为验证坐标样式,然后更新示例,使文档中说明的定位方式正确且一致。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, react
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100