Last active
November 23, 2016 14:30
-
-
Save darekrossman/ff8e61c89c59452d12a48f716ded83e5 to your computer and use it in GitHub Desktop.
A React snippet for scaffolding out a stateless functional component, using Flow for prop types and custom HOCs for themability.
This file contains hidden or 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
'Stateless React Component': | |
'prefix': 'srcc' | |
'body': ''' | |
// @flow | |
import React, { PropTypes } from 'react'; | |
import { compose } from 'recompose'; | |
import { withStyles } from '_util/HOCs'; | |
import { FlexBox } from '@madmobilenpm/mmui'; | |
type Props = { | |
}; | |
type WrappedProps = { | |
styles: Styles | |
}; | |
const componentStyles: StyleFn = ({ theme: { colors } }) => ({ | |
container: {} | |
}); | |
export const BaseComponent: Component<WrappedProps> = ({ styles }) => | |
<FlexBox style={styles.container}> | |
Hello :) | |
</FlexBox>; | |
export const enhancer = compose( | |
withStyles(componentStyles) | |
); | |
const WrappedComponent: Component<Props> = enhancer(BaseComponent); | |
export default WrappedComponent; | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still trying to find the right pattern for typing props that should be provided to the component from the outside - and props that are added to the component from HOCs.