Skip to content

Instantly share code, notes, and snippets.

@namuol
Last active September 1, 2015 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namuol/193f1f4d5e71d1305bac to your computer and use it in GitHub Desktop.
Save namuol/193f1f4d5e71d1305bac to your computer and use it in GitHub Desktop.
React Styles
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>;
}
}
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