Skip to content

Instantly share code, notes, and snippets.

@richsoni
Created July 1, 2015 19:26
Show Gist options
  • Save richsoni/8332c99cf6028ae9b310 to your computer and use it in GitHub Desktop.
Save richsoni/8332c99cf6028ae9b310 to your computer and use it in GitHub Desktop.
React Props for style
var style = {
myDiv: {
backgroundColor: 'red',
}
}
class Child extends React.Component {
render() {
return <div style={_.extend({}, style.myDiv, this.props.style, {color: 'blue'})} />
}
}
Child.propTypes = {
style: React.PropTypes.object,
}
Child.defaultProps = {
style: {},
}
class Parent extends React.Component {
render() {
return <Child
style={fontSize: 20}
/>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment