Created
July 1, 2015 19:26
-
-
Save richsoni/8332c99cf6028ae9b310 to your computer and use it in GitHub Desktop.
React Props for style
This file contains hidden or 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
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