Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议修改:使用循环的 index 变量作为 key 是一种反优化 #2

Open
MoNodin opened this issue May 13, 2019 · 2 comments
Open

Comments

@MoNodin
Copy link

MoNodin commented May 13, 2019

编译小程序时提示:
编译 组件文件 node_modules/mounted/src/components/PickerView/index.tsx
建议修改:使用循环的 index 变量作为 key 是一种反优化。参考:https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md

189 | }
190 | return (<PickerView value={fullSelectedIndexes} className={m-picker-view ${disabled && 'm-picker-view_disabled'} ${className}} style={styles.view} indicatorStyle={height:${styles.indicator.height}} onPickStart={this.props.onPickStart} onPickEnd={this.props.onPickEnd} onChange={this.handleChange}>

191 | {normalizedData.map((colData, colIndex) => (
| ^^^^^^^^
192 | <PickerViewColumn key={column-${colIndex}}>
193 | {colData.map((item, itemIndex) => (
194 |

@fjc0k
Copy link
Owner

fjc0k commented May 13, 2019

这个不用管哈 不影响

@github65535
Copy link

触发规则:render树进行diff时,没有发生变化的element就不做更改

以下情况可忽略此错误:

  1. 列表不被计算和改变。
  2. 列表项没有ID属性
  3. 列表不会执行重排或筛选操作

参考资料

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants