개발자 99% 커뮤니티에서 수다 떨어요!
====================================================================
<MobileCarrier text={'SKT'}/>
<MobileCarrier text={'KT'}/>
<MobileCarrier text={'LG U+'}/>
<MobileCarrier text={'알뜰폰'}/>
여기는 메인입니다 메인에선 이렇게 줄여서 쓰고 싶은데요 문제는 밑에 코드가
MobileCarrier로 컴포넌트화 시킨건데요
=======================================================================
// React Component
import {StyleSheet, Text, Pressable, Platform } from 'react-native';
import React, { useEffect, useState } from "react";
import { width, height } from '../../enum/size';
function mobileCarrier({text, mobileCarrierBorder}) {
const [mobileCarrierBorders, setMobileCarrierBorders] = useState('');
const [temp, setTemp] = useState('');
// setMobileCarrierBorders(mobileCarrierBorder)
return (
<Pressable onPress={(onPress) => {
if (mobileCarrierBorder === text) {
mobileCarrierBorder('')
}
if (mobileCarrierBorder === ''){
mobileCarrierBorder(text)
}
console.log(mobileCarrierBorders)
console.log(mobileCarrierBorder)
}}
>
<Text style={mobileCarrierBorder !== '' ? { ...styles.mobileText, borderColor: '#101010', fontWeight: 'bold', color: '#101010' } : styles.mobileText}>{text}</Text>
</Pressable>
)
};
const styles = StyleSheet.create({
mobileText: {
marginTop: height * 10,
width: width * 75,
height: height * 50,
fontSize: width * 12,
fontWeight: 'normal',
color: 'gray',
borderRadius: 2,
backgroundColor: "#ffffff",
borderStyle: "solid",
borderWidth: 1,
textAlign: "center",
textAlignVertical: "center",
borderColor: "#e2e2e2",
},
})
export default mobileCarrier;
회원가입 페이지 기능을 구현중입니다 그 중에서 휴대폰 통신사 선택하는 건데요
SKT | KT | LG U+ | 알뜰폰
이렇게 있으면 클릭하면 BorderColor이 검은색으로 바뀌게 해놨습니다
문제는 SKT가 클릭되어 있는 상황에서 다른 걸 클릭하면 SKT의 BorderColor가 검은색이었던 걸
초기값인 회색으로 바꾸고 클릭한 다른 부분을 검은색으로 만들고 싶습니다 근데 어떻게 해야할 지 모르겠네요 ㅠㅠ
좀 도와주실 분 계시나요 ㅠㅠ