Last active
August 21, 2017 17:49
-
-
Save ssomnoremac/21ea4032c4bf5044e7fc34fe7f44a341 to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
import { | |
View, | |
Image, | |
ListView, | |
ScrollView, | |
Text, | |
TouchableHighlight, | |
TouchableNativeFeedback, | |
TouchableOpacity, | |
TouchableWithoutFeedback, | |
StyleSheet | |
} from 'react-native' | |
let Styled = {} | |
const StyledComponent = (Component) => (styles) => (props) => { | |
const { | |
styles: inlineStyles, | |
children, | |
...otherProps, | |
} = props | |
const cachedStyles = StyleSheet.create(styles) | |
return( | |
<Component style={[cachedStyles, inlineStyles]} {...otherProps}> | |
{children} | |
</Component> | |
) | |
}; | |
Styled.View = StyledComponent(View) | |
Styled.Image = StyledComponent(Image) | |
Styled.ListView = StyledComponent(ListView) | |
Styled.ScrollView = StyledComponent(ScrollView) | |
Styled.Text = StyledComponent(Text) | |
Styled.TouchableHighlight = StyledComponent(TouchableHighlight) | |
Styled.TouchableNativeFeedback = StyledComponent(TouchableNativeFeedback) | |
Styled.TouchableOpacity = StyledComponent(TouchableOpacity) | |
Styled.TouchableWithoutFeedback = StyledComponent(TouchableWithoutFeedback) | |
export default Styled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment