react native - style pattern part1 - 조건문과 오버라이딩

sangwoo noh·2022년 9월 3일
0

react native

목록 보기
6/16

조건문과 오버라이딩

...
<Text
  style={[
    styles.sectionTitle,
    {
      color: isDarkMode ? Colors.white : Colors.black,
    },
  ]}>
  {title}
</Text>
...
// 위 기괴한 문법은 styles.sectionTitle이 먼저 적용된 후,
color부분이  (isDarkMode ? Colors.white : Colors.black) 의 조건에따라 덮어씌워진다. 

const styles = StyleSheet.create({
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
  },
  highlight: {
    fontWeight: '700',
  },
});
profile
하기로 했으면 하자

0개의 댓글