Skip to content

Instantly share code, notes, and snippets.

@statianzo
Forked from ssomnoremac/Styled.js
Created April 9, 2017 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statianzo/a6b51e5b1768cd63892950af6314c03a to your computer and use it in GitHub Desktop.
Save statianzo/a6b51e5b1768cd63892950af6314c03a to your computer and use it in GitHub Desktop.
import React from 'react';
import {
View,
Image,
ListView,
ScrollView,
Text,
TouchableHighlight,
TouchableNativeFeedback,
TouchableOpacity,
TouchableWithoutFeedback,
} from 'react-native'
let Styled = {}
const StyledComponent = (Component) => (styles) => (props) => {
const {
styles: inlineStyles,
children,
...otherProps,
} = props
return(
<Component style={[styles, 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