이 컴포넌트에서 hasMarginBottom 값이 true라면 하단에 여백을 지정해줬습니다. 다음 컴포넌트도 hasMarginBottom Props로 하단 여백을 지정할 수 있고, onPresstitle로 버튼을 클릭했을 때 실행할 함수와 버튼의 이름을 지정할 수 있습니다.

    components/CustomButton.js

    import React from 'react';
    import {StyleSheet, View, Pressable, Text, Platform} from 'react-native';
    
    function CustomButton({onPress, title, hasMarginBottom}) {
      return (
        <View style={[styles.block, hasMarginBottom && styles.margin]}>
          <Pressable
            onPress={onPress}
            style={({pressed}) => [
              styles.wrapper,
              Platform.OS === 'ios' && pressed && {opacity: 0.5},
            ]}
            android_ripple={{
              color: '#ffffff',
            }}>
            <Text style={[styles.text]}>{title}</Text>
          </Pressable>
        </View>
      );
    }
    
    const styles = StyleSheet.create({
      overflow: {
        borderRadius: 4,
        overflow: 'hidden',
      },
      wrapper: {
        borderRadius: 4,
        height: 48,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: '#6200ee',
      },
      text: {
        fontWeight: 'bold',
        fontSize: 14,
        color: 'white',
      },
      margin: {
        marginBottom: 8,
      },
    });
    
    export default CustomButton;
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.