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

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

류지혜님의 프로필 이미지
류지혜

작성한 질문수

Slack 클론 코딩[실시간 채팅 with React]

메뉴 만들기

(참고) Menu' components don't accept text as child elements. 오류

작성

·

322

2

 

오류 원문

  • 'Menu' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element'.

 

Workspace/index.tsx에서 오류

  • Menu 컴포넌트에서 interface Props를 children 부분에서 오류 난 것

 

코드

  • 이전 코드(components/Menu/index.tsx)

    interface Props {
      show: boolean;
      onCloseModal: (e: any) => void;
      style: CSSProperties;
      closeButton?: boolean;
      children: JSX.Element;
    }

     

  • 수정 코드(components/Menu/index.tsx)

    interface Props {
      show: boolean;
      onCloseModal: (e: any) => void;
      style: CSSProperties;
      closeButton?: boolean;
      children: React.ReactNode;
    }


답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
류지혜님의 프로필 이미지
류지혜

작성한 질문수

질문하기