Skip to content

Commit

Permalink
Apply keys
Browse files Browse the repository at this point in the history
  • Loading branch information
nkhadka committed May 10, 2017
1 parent 4436281 commit 0308af5
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,32 @@ class Tabs extends Component {
}
});
}
return (
<View style={[styles.tabbarView, this.props.style, this.state.keyboardUp && styles.hidden]}>
{React.Children.map(this.props.children.filter(c=>c),(el)=>
<TouchableOpacity key={el.props.key}
testID={el.props.testID}
style={[ styles.iconView,
this.props.iconStyle,
(el.props.name || el.key) == selected
? this.props.selectedIconStyle || el.props.selectedIconStyle || {}
: {} ]}
onPress={()=>!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 ))}
</TouchableOpacity>
)}
</View>
);
return (
<View style={[styles.tabbarView, this.props.style, this.state.keyboardUp && styles.hidden]}>
{React.Children.map(this.props.children.filter(c=>c),(el)=>
<TouchableOpacity key={el.props.childKey}
testID={el.props.testID}
style={[ styles.iconView,
this.props.iconStyle,
(el.props.name || el.key) == selected
? this.props.selectedIconStyle || el.props.selectedIconStyle || {}
: {} ]}
onPress={()=>!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}) ))}
</TouchableOpacity>
)}
</View>
)
}
}
var styles = StyleSheet.create({
Expand Down

0 comments on commit 0308af5

Please sign in to comment.