Created
July 28, 2015 13:20
-
-
Save AndrewIngram/9259379cb017ad855584 to your computer and use it in GitHub Desktop.
Composing propTypes
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
import React from 'react'; | |
import omit from 'object.omit'; | |
import ResponsiveImage from './ResponsiveImage'; | |
class SlideshowImage extends React.Compoent { | |
static propTypes = { | |
slide: React.PropTypes.shape(omit(ResponsiveImage.propTypes, 'defaultWidth')), | |
opacity: React.PropTypes.number, | |
left: React.PropTypes.number, | |
} | |
render() { | |
const {slide, opacity, left} = this.props; | |
return ( | |
<div className="SlideshowImage" style={{left: `${left}%`}}> | |
<div className="SlideshowImage__Image" style={{opacity}}> | |
<ResponsiveImage defaultWidth={812} {...slide} /> | |
</div> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Main issue is probably that unless there's an idiomatic way of doing this, we're going to screw up things like eslint's propTypes warnings