You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Conditional <Panel /> makes rc-collapse crash on child.key #41
However, when the evaluation of content.location returns false, and no <Panel /> is inserted, rc-collapse breaks because it expects a child with a .key property:
TypeError: null is not an object (evaluating 'child.key')
If rc-collapse would check if child exists before reading key, it would allow us to dynamically insert <Panel />s based on conditions, like in the example above.
Activity
shepherdwind commentedon Oct 10, 2016
That because Panel should not be null, You can filter empty child like this
And I will fix this soon.
ystarlongzi commentedon Nov 17, 2016
@shepherdwind
刚好今天也碰到这个问题,采用的方法和 @jorisw 类似,并且你推荐的方案确实可行。但在实际开发中,相信大部分开发者默认也会使用 @jorisw 这种方式吧。
感觉如果在
<Collapse />组件内部对值为null、undefined、false的子元素过滤掉,这样应该对开发更友好吧。还是说作者有其它设计意图?
afc163 commentedon Nov 17, 2016
其他组件也都优化了,可以改下:
react-component/menu#57
react-component/tabs#31
@ystarlongzi 来个 PR 如何?
ystarlongzi commentedon Nov 17, 2016
@afc163 好的,等下提交下