import React from 'react'; import { View, ViewStyle } from 'react-native'; interface PixelSpacerProps { space: number; flex?: never; horizontal?: boolean; } interface FlexSpacerProps { space?: never; flex: number; horizontal?: boolean; } /** * 가급적 사용을 자제해주세요. 뷰 개수가 과도하게 많아지면 성능에 영향을 줄 수 있습니다. * 인접 뷰의 margin style 을 대신 사용해주세요. */ export const Spacer: React.FC = (props) => { const { space, flex, horizontal } = props; if (space !== undefined && space <= 0) { return null; } if (flex !== undefined && flex <= 0) { return null; } const isHorizontal = horizontal === true; const style: ViewStyle = { height: isHorizontal ? 1 : space, width: isHorizontal ? space : 1, flex: flex, flexDirection: isHorizontal ? 'row' : 'column', }; return ; };