Last active
September 1, 2015 23:35
-
-
Save namuol/193f1f4d5e71d1305bac to your computer and use it in GitHub Desktop.
React Styles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const styles = StyleSheet.create({ | |
list: { /* etc */ }, | |
hover: { /* etc */ }, | |
}); | |
export default class List extends React.Component { | |
static propTypes = { | |
style: React.PropTypes.style, | |
hoverStyle: React.PropTypes.style, | |
}; | |
render () { | |
return <div style={[ | |
// Default base styles: | |
styles.list, | |
// "User" base styles: | |
this.props.style, | |
// Default hover styles: | |
this.state.hover && styles.hover, | |
// "User" hover styles: | |
this.state.hover && this.props.hoverStyle, | |
]}> | |
{this.props.items.map((content) => | |
<div> | |
{content} | |
</div> | |
)} | |
</div>; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myStyles = StyleSheet.create({ | |
list: { /* etc */ }, | |
hover: { /* etc */ }, | |
}); | |
<List | |
items={['Eggs', 'Milk', 'Butter']} | |
style={myStyles.list} | |
hoverStyle={myStyles.hover} | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment