그러면 이제 About 컴포넌트에서 location.search 값에 있는 detailtrue인지 아닌지에 따라 추가 정보를 보여 주도록 만들겠습니다. About 컴포넌트를 다음과 같이 수정해 보세요.

    About.js

    import React from 'react';
    import qs from 'qs';
     
    const About = ({ location }) => {
      const query = qs.parse(location.search, {
        ignoreQueryPrefix: true //  설정을 통해 문자열  앞의 ? 생략합니다.
      });
      const showDetail = query.detail === 'true'; // 쿼리의 파싱 결과 값은 문자열입니다.
      return (
        <div>
          <h1>소개</h1>
          <p> 프로젝트는 리액트 라우터 기초를 실습해 보는 예제 프로젝트입니다.</p>
          {showDetail && <p>detail 값을 true 설정하셨군요!</p>}
        </div>
      );
    };
     
    export default About;

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.