인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

cmj021002님의 프로필 이미지

작성한 질문수

아바타 커뮤니티앱 만들기 (React Native)

[3-3] 로그인/회원가입 스크린 마크업

style 에러

해결된 질문

작성

·

63

0

안녕하세요 강사님 코드를 따라치면서 학습을 하고 있는데

<View style={styles.fixed}>

이 style 부분에

No overload matches this call.
Overload 1 of 2, '(props: ViewProps): View', gave the following error.
Type '{ position: string; bottom: number; width: string; borderTopWidth: number; borderTopColor: string; paddingTop: number; paddingHorizontal: number; }' is not assignable to type 'StyleProp<ViewStyle>'.
Type '{ position: string; bottom: number; width: string; borderTopWidth: number; borderTopColor: string; paddingTop: number; paddingHorizontal: number; }' is not assignable to type 'ViewStyle'.
Types of property 'position' are incompatible.
Type 'string' is not assignable to type '"absolute" | "static" | "relative" | "fixed" | "sticky" | undefined'.
Overload 2 of 2, '(props: ViewProps, context: any): View', gave the following error.
Type '{ position: string; bottom: number; width: string; borderTopWidth: number; borderTopColor: string; paddingTop: number; paddingHorizontal: number; }' is not assignable to type 'StyleProp<ViewStyle>'.
Type '{ position: string; bottom: number; width: string; borderTopWidth: number; borderTopColor: string; paddingTop: number; paddingHorizontal: number; }' is not assignable to type 'ViewStyle'.
Types of property 'position' are incompatible.
Type 'string' is not assignable to type '"absolute" | "static" | "relative" | "fixed" | "sticky" | undefined'.ts(2769)

ViewPropTypes.d.ts(203, 3): The expected type comes from property 'style' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<View> & Readonly<ViewProps>'

ViewPropTypes.d.ts(203, 3): The expected type comes from property 'style' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<View> & Readonly<ViewProps>'

(property) style?: StyleProp<ViewStyle>

View Problem (Alt+F8)



이런 에러가 뜨는데 제가 어느 부분에서 잘못했는지, 왜 이런 에러가 발생했는지 모르겠습니다....

전체 코드는 아래와 같습니다.

import CustomButton from '@/components/CustomButton';
import InputFiled from '@/components/InputFiled';
import { colors } from '@/constants';
import { StyleSheet, View } from 'react-native';

export default function LoginScreen() {
  return (
    <>
      <View style={styles.container}>
        <InputFiled
          label="이메일"
          placeholder="이메일을 입력해주세요"
        ></InputFiled>
        <InputFiled
          label="비민번호"
          placeholder="비밀번호를 입력해주세요"
        ></InputFiled>
      </View>
      <View style={styles.fixed}>
        <CustomButton label="로그인하기"></CustomButton>
      </View>
    </>
  );
}

const styles = {
  container: {
    flex: 1,
    margin: 16,
    gap: 16,
  },
  fixed: {
    position: 'absolute',
    bottom: 0,
    width: '100%',
    borderTopWidth: StyleSheet.hairlineWidth,
    borderTopColor: colors.GRAY_300,
    paddingTop: 12,
    paddingHorizontal: 16,
  },
};

답변 1

0

Kyo님의 프로필 이미지
Kyo
지식공유자

스타일 코드를 선언할때, const styles = StyleSheet.create({}) 로 해보시겠어요?