Skip to content

Instantly share code, notes, and snippets.

@jasonmerino
Last active October 7, 2019 19:01
Show Gist options
  • Save jasonmerino/97a6531835ca4525ec99dedb39d99030 to your computer and use it in GitHub Desktop.
Save jasonmerino/97a6531835ca4525ec99dedb39d99030 to your computer and use it in GitHub Desktop.
import React, { FC } from 'react';
import { ViewProps, View, FlexAlignType } from 'react-native';
interface IProps extends ViewProps {
alignVertical?:
| 'flex-start'
| 'flex-end'
| 'center'
| 'space-between'
| 'space-around'
| 'space-evenly';
alignHorizontal?: FlexAlignType;
flex?: boolean;
}
export const Column: FC<IProps> = props => {
const { style, flex, alignVertical, alignHorizontal, ...viewProps } = props;
const styles = [style];
if (flex) {
styles.push({ flex: 1 });
}
if (alignVertical !== undefined) {
styles.push({ justifyContent: alignVertical });
}
if (alignHorizontal !== undefined) {
styles.push({ alignItems: alignHorizontal });
}
return <View style={styles} {...viewProps} />;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment