13
React 获取key 失败
source link: https://segmentfault.com/a/1190000040001455
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
React 获取key 失败
发布于 今天 08:02
English在组件中获取 this.props.key
将得到 undefined
。
大部分 JSX 元素上的 props 都会被传入组件,然而有两个特殊的 props (ref
和 key
) 已经被 React 所使用,不会被传入组件。
用一个不同的 prop 传入 <ListItem key={result.id} id={result.id} />
。虽然这似乎是多余的,但是将应用程序逻辑和协调提示(reconciliation hints)分开是很重要的。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK