components/WriteHeader.js
import {useNavigation} from '@react-navigation/native'; import React from 'react'; import {StyleSheet, View} from 'react-native'; import TransparentCircleButton from './TransparentCircleButton'; function () { const navigation (); const () => { navigation. (); }; return ( <View style={styles.block}> <View style={styles.iconButtonWrapper}> <TransparentCircleButton onPress={onGoBack} name="arrow-back" color="#424242" /> </View> <View style={styles.buttons}> <TransparentCircleButton name="delete-forever" color="#ef5350" hasMarginRight /> <TransparentCircleButton name="check" color="#009688" /> </View> </View> ); } const styles StyleSheet. ({ block: { height: 48, paddingHorizontal: 8, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', }, buttons: { flexDirection: 'row', alignItems: 'center', }, }); export default WriteHeader;
컴포넌트의 코드가 훨씬 간결해졌지요? 이제 이 컴포넌트를 WriteScreen에서 사용해 컴포넌트가 잘 나타나는지 확인해보세요.