From 0308af5cd2b52cb7031bb1061ff6e722a27edc4c Mon Sep 17 00:00:00 2001 From: nkhadka Date: Wed, 10 May 2017 14:38:42 +0545 Subject: [PATCH] Apply keys --- index.js | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index 959222b..48357a3 100644 --- a/index.js +++ b/index.js @@ -58,31 +58,32 @@ class Tabs extends Component { } }); } - return ( - - {React.Children.map(this.props.children.filter(c=>c),(el)=> - !self.props.locked && self.onSelect(el)} - onLongPress={()=>self.onSelect(el)} - activeOpacity={el.props.pressOpacity}> - {el.props.children.map(c => ( - selected == (el.props.name || el.key) - ? React.cloneElement(c, - { selected: true, - style: [ c.props.style, - this.props.selectedStyle, - c.props.selectedStyle ]}) - : c ))} - - )} - - ); + return ( + + {React.Children.map(this.props.children.filter(c=>c),(el)=> + !self.props.locked && self.onSelect(el)} + onLongPress={()=>self.onSelect(el)} + activeOpacity={el.props.pressOpacity}> + {el.props.children.map((c,i) => ( + selected == (el.props.name || el.key) + ? React.cloneElement(c, + { selected: true, + key: i, + style: [ c.props.style, + this.props.selectedStyle, + c.props.selectedStyle ]}) + : React.cloneElement(c, {key: i+10}) ))} + + )} + + ) } } var styles = StyleSheet.create({