Skip to content

Instantly share code, notes, and snippets.

@peterlazar1993
Created May 1, 2016 17:16
Show Gist options
  • Save peterlazar1993/c9b092bb2fe641fafcaf2f0a150161a9 to your computer and use it in GitHub Desktop.
Save peterlazar1993/c9b092bb2fe641fafcaf2f0a150161a9 to your computer and use it in GitHub Desktop.
import React, { Component, StyleSheet, View } from 'react-native';
import Emoji from './emoji';
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
justifyContent: 'space-around',
marginTop: 5,
marginBottom: 5,
},
});
export default class EmojiStrip extends Component {
constructor(props) {
super(props);
this.state = { selected: null, emoji: 'hello' };
this.emojis = ['smiley', 'neutral_face', 'disappointed', 'x'];
}
onSelectEmoji = (emoji) => this.setState({ selected: emoji });
isEmojiSelected = (emoji) => {
if (this.state.selected === emoji) {
return true;
}
return false;
}
renderEmojis = () => this.emojis.map((emoji, index) =>
<Emoji
key={index}
emoji={emoji}
enabled={this.isEmojiSelected(emoji)}
onSelectEmoji={this.onSelectEmoji}
/>
);
render() {
return (
<View style={styles.container}>
{
this.renderEmojis()
}
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment