inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

React 기반 Gatsby로 기술 블로그 개발하기

메인 페이지에서 Props로 받아 포스트 데이터 출력하기

index.tsx 에러

230

ibanez88

작성한 질문수 1

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 컴포넌트에 변경 사항을 제대로 반영하는 단계를 제대로 진행하지 못한 것으로 추측하고 있습니다.

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

 

blog Gatsby

답변 1

0

주현도

안녕하세요, ibanez88님!

 

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

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

 

0

ibanez88

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

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

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

 

쿼리오류 Field "thumbnail" must not have a selection...

1

871

1

타입스크립트를 설정할 때 jsxPragma 옵션을 뺀 이유는 무엇인가요?

1

605

1

마지막 배포 부분 질문드립니다!

1

623

1

'[username]/[username].github.io' -> 'username/reponame'

0

344

0

IntersectionObserver deploy( gatsby build) 시 오류(자답)

1

399

1

PostHead.tsx BackgroundImage 동작오류(자답)

1

296

0

19강 인피니티 스크롤 IntersectionObserver 코드 위치 수정이 필요합니다.

1

411

1

썸네일 이미지 제작 및 학습 방법 관련 문의

1

446

1

배포 후 포스트 업로드 방법

1

386

1

배포 질문이요!

1

527

1

gatsby develop 오류

1

940

1

깃허브 레퍼지토리 질문드려요

1

344

1

특정 게시글을 클릭하여 상세 페이지로 넘어가는 과정과 SPA에 관한 질문

1

285

1

Unhandled Runtime Error 가 뜹니다

0

506

2

sign in with GitHub 클릭 시

1

394

3

동작 반복 시 오류

1

351

2

const BackgroundImage 질문

1

212

1

오타 문의

1

305

2

Props로 받아 포스트 데이터 출력하기가 안됩니다.

1

203

1

index.tsx allMarkdownRemark 에러..

0

595

2

스네이크 케이스로 변수명을 짓는 이유

1

251

1

'Tagged Template Literal 방식을 통해 정의한 CSS 적용 방법'에서 발생하는 문제

3

352

2

상단 이미지를 썸네일 사용하지않고 다른 이미지를 쓰고싶습니다

1

284

1

여기까지 했는데 runtime 에러가 발생합니다

2

285

1