• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

index.tsx 에러

21.12.11 00:15 작성 조회수 139

1

현도님 안녕하세요!
꼼꼼한 강의를 공유해주셔서 정말 감사합니다 : )

아직 코드 전부를 이해하지 못하고 그대로 실습 코드를 따라가던 중 src/pages/index.tsx 파일에서 에러가 발생했습니다. 현재 코드는 아래와 같습니다. 

import React, { FunctionComponent } from 'react'
import styled from '@emotion/styled'
import GlobalStyle from 'components/Common/GlobalStyle'
import Footer from 'components/Common/Footer'
import CategoryList from 'components/Main/CategoryList'
import Introduction from 'components/Main/Introduction'
import PostList from 'components/Main/PostList'
import { graphql } from 'gatsby'
import { PostListItemType } from 'types/PostItem.types'

const CATEGORY_LIST = {
All: 5,
Web: 3,
Mobile: 2,
}

const Container = styled.div`
display: flex;
flex-direction: column;
height: 100%;
`

type IndexPageProps = {
data: {
allMarkdownRemark: {
edges: PostListItemType[]
}
}

const IndexPage: FunctionComponent<IndexPageProps> = function ({
data: {
// data: 쿼리를 통해 받은 데이터가 담겨있는 props
allMarkdownRemark: { edges }, // edges: 각 파일의 데이터가 들어있는 배열
},
}) {
return (
<Container>
<GlobalStyle />
<Introduction />
<CategoryList selectedCategory="Web" categoryList={CATEGORY_LIST} />
<PostList posts={edges} />
<Footer />
</Container>
)
}

export default IndexPage

export const getPostList = graphql`
query getPostList {
allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date, frontmatter___title] }
) {
edges {
node {
id
frontmatter {
title
summary
date(formatString: "YYYY.MM.DD.")
categories
thumbnail {
publicURL
}
}
}
}
}
}
`

에러 메시지가 이와 같이 IndexPage를 선언하는 부분부터 나타나는데, Member 'const' implicitly has an 'any' type.
아마도 IndexPage 컴포넌트에 변경 사항을 제대로 반영하는 단계를 제대로 진행하지 못한 것으로 추측하고 있습니다.

어떠한 방향으로 해결하면 좋을지 감을 잡기가 어려워서 이렇게 문의드립니다. 
 

 

답변 1

답변을 작성해보세요.

0

안녕하세요, ibanez88님!

 

지금 IndexPageProps 타입을 설정하는 부분에서 중괄호의 짝이 안맞는게 보이네요!

마지막에 중괄호를 닫아주시고 한 번 해보시겠어요?

 

ibanez88님의 프로필

ibanez88

질문자

2021.12.13

중괄호 하나가 빠져있었네요!! 감사합니다!!

늘 오타 체크를 한다고 하는데도 종종 이렇습니다ㅜㅜ

좋은 강의 올려주셔서 다시 한 번 감사드립니다 : )