Created
May 23, 2017 17:13
-
-
Save alenia/e1bd90fc3fe71c41ad9db5a997037061 to your computer and use it in GitHub Desktop.
types of components
This file contains 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
// 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