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

当key为0的时候,BannerAnim. getRenderChildren 报错,但是react支持这种逻辑 #9

Closed
iwege opened this issue Apr 18, 2017 · 3 comments

Comments

@iwege
Copy link

iwege commented Apr 18, 2017

报错地址为:
https://github.com/react-component/banner-anim/blob/master/src/BannerAnim.jsx#L102

常规情况下,拿到数组之后会直接

 var children  = data.map((val,key)=>{<element key={key} />});

在这种情况下直接判断!item.key是不正确的。

目前的workaroud是将key变为字符串。这样才正常。

@jljsj33
Copy link
Member

jljsj33 commented Apr 18, 2017

 const children = data.map((val, key) => (<element key={`${key}`} />));

建议不要直接 number。。。。转一下吧。。。

@jljsj33
Copy link
Member

jljsj33 commented Apr 18, 2017

https://facebook.github.io/react/docs/lists-and-keys.html#extracting-components-with-keys 官方建议 key 是转成 string 类型的。。。

@iwege
Copy link
Author

iwege commented Apr 18, 2017

明白了,能在error里面提一句么?

@iwege iwege closed this as completed Apr 18, 2017
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

2 participants