inflearn logo
강의

Course

Instructor

Developing a Tech Blog with React-Based Gatsby

Displaying optimized thumbnail images with the gatsby-plugin-image library

childImageSharp가 자꾸 null이라고 뜨네요..ㅠ

455

hjo38863616

1 asked

1

다시 되돌아가서 쭉 훑어봤는데, 오타나 잘못친게 없는데 자꾸 이런 에러가 나오네요..

blog Gatsby

Answer 4

8

kwb0203121028

해결 하셨을진 모르겠지만,

루트 폴더를 새로 생성하거나 직접적인 변경이 있을경우

쉘에서 종료시킨 후 재시작을 하면 원활하게 데이터 조회가 가능하십니다

0

chotg

우빈형님 감사함돠

0

ji5485

Root Directory > static 디렉토리 안에 파일명이 "profile-image"인 이미지 파일을 추가해주셨는지 확인 부탁드려요!

만약 이미지가 있는데도 오류가 뜬다면 깃허브에 프로젝트 전부 올려주신 후, 레포지토리 주소 올려주시면 확인해보겠습니다 :)

0

hjo38863616

해당 index.tsx의 코드는 아래와 같습니다.

깃허브에는 아직 업로드 하지 않았는데, 보시고 만약 더 필요하시면 깃허브에 업로드할게요!

-----

import React, { FunctionComponent } from 'react';
import styled from '@emotion/styled';
import GlobalStyle from '../components/Common/GlobalStyle';
import Introduction from '../components/Main/Introduction';
import CategoryList from '../components/Main/CategoryList';
import Footer from '../components/Common/Footer';
import PostList, { PostType } from '../components/Main/PostList';
import { ProfileImageProps } from '../components/Main/ProfileImage';
import { graphql } from 'gatsby';

interface IndexPageProps {
  data: {
    allMarkdownRemark: {
      edges: PostType[];
    };
    file: {
      childImageSharp: {
        fluid: ProfileImageProps['profileImage'];
      };
    };
  };
}

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

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

const IndexPage: FunctionComponent<IndexPageProps> = function ({
  data: {
    allMarkdownRemark: { edges },
    file: {
      childImageSharp: { fluid },
    },
  },
}) {
  return (
    <Container>
      <GlobalStyle />
      <Introduction profileImage={fluid} />
      <CategoryList selectedCategory="Web" categoryList={CATEGORY_LIST} />
      <PostList posts={edges} />
      <Footer />
    </Container>
  );
};

export default IndexPage;

export const queryPostList = graphql`
  query queryPostList {
    allMarkdownRemark(
      sort: { order: DESC, fields: [frontmatter___date, frontmatter___title] }
    ) {
      edges {
        node {
          id
          frontmatter {
            title
            summary
            date(formatString: "YYYY.MM.DD.")
            categories
            thumbnail {
              childImageSharp {
                fluid(
                  maxWidth: 768
                  maxHeight: 200
                  fit: INSIDE
                  quality: 100
                ) {
                  ...GatsbyImageSharpFluid_withWebp
                }
              }
            }
          }
        }
      }
    }
    file(name: { eq: "profile-image" }) {
      childImageSharp {
        fluid(maxWidth: 120, maxHeight: 120, fit: INSIDE, quality: 100) {
          ...GatsbyImageSharpFluid_withWebp
        }
      }
    }
  }
`;

0

ji5485

안녕하세요, 몽키스님.

혹시 프로젝트를 깃허브에 업로드하셨다면 링크 답변으로 남겨주시면 감사하겠습니다.

아니면 해당 부분 소스코드 전부 답변으로 달아주세요!

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

1

852

1

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

1

585

1

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

1

617

1

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

0

337

0

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

1

387

1

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

1

288

0

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

1

402

1

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

1

436

1

배포 후 포스트 업로드 방법

1

378

1

배포 질문이요!

1

512

1

gatsby develop 오류

1

932

1

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

1

340

1

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

1

280

1

Unhandled Runtime Error 가 뜹니다

0

502

2

sign in with GitHub 클릭 시

1

393

3

동작 반복 시 오류

1

350

2

const BackgroundImage 질문

1

209

1

오타 문의

1

299

2

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

1

200

1

index.tsx allMarkdownRemark 에러..

0

591

2

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

1

248

1

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

3

344

2

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

1

280

1

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

2

278

1