Skip to content

Instantly share code, notes, and snippets.

@AndrewIngram
Created July 28, 2015 13:20
Show Gist options
  • Save AndrewIngram/9259379cb017ad855584 to your computer and use it in GitHub Desktop.
Save AndrewIngram/9259379cb017ad855584 to your computer and use it in GitHub Desktop.
Composing propTypes
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>
);
}
}
@AndrewIngram
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment