查找: 修改 Props
找错误 简单
题目
什么是 错误使用这个组件?
代码
function Welcome({ name }) {
name = name.toUpperCase();
return <h1>Hello, {name}!</h1>;
}
提示
Props 应该是 treated as 读取-仅.
解释
The component modifies the name prop directly. Props are read-only and should never be mutated. The fix is to create a local variable: const upperName = name.toUpperCase(); or inline it: {name.toUpperCase()}.
相关资源
相关课程
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。