Skip to content

Instantly share code, notes, and snippets.

@alenia
Created May 23, 2017 17:13
Show Gist options
  • Save alenia/e1bd90fc3fe71c41ad9db5a997037061 to your computer and use it in GitHub Desktop.
Save alenia/e1bd90fc3fe71c41ad9db5a997037061 to your computer and use it in GitHub Desktop.
types of components
// fails linter
myComponent1 = ({tintColor}) => <Image style={{tintColor}} />
// passes linter
myComponent2 = ({tintColor}) => <Image style={{tintColor}} />
myComponent2.propTypes = {
tintColor: PropTypes.string.isRequired
}
// fails linter
class MyComponent3 extends Component {
render() {
const {tintColor} = this.props
return <Image style={{tintColor}} />
}
}
// passes linter
class MyComponent3 extends Component {
static propTypes = {
tintColor: PropTypes.string.isRequired
}
render() {
const {tintColor} = this.props
return <Image style={{tintColor}} />
}
}
// passes linter
class MyComponent4 extends Component {
render() {
const {tintColor} = this.props
return <Image style={{tintColor}} />
}
}
MyComponent4.propTypes = {
tintColor: PropTypes.string.isRequired
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment