다음은 template 으로 navigate 한 예제이다.
import React, { useEffect } from 'react';
import { navigate } from 'gatsby';
const IndexPage = ({ pageContext }) => {
const { lastItem } = pageContext;
useEffect(() => {
if (lastItem && lastItem.id) {
navigate(`/${lastItem.id}`);
}
}, [lastItem]);
return (
<div>
<h1>Hello World</h1>
</div>
)
}
export default IndexPage;
'웹' 카테고리의 다른 글
nodejs, reactjs) 외국인 대상으로 서비스 만들기 - 9일차 - 2024.06.15 (0) | 2024.06.15 |
---|---|
gatsby) github.io pages 이용 file hosting - 개발 일지 8 (0) | 2024.06.14 |
nodejs, reactjs) comment 댓글 기능 view model controller - 개발 기록 5 (0) | 2024.06.05 |
사전 참여 아이디어 - online to offline - 무형을 유형으로 증명 (0) | 2024.06.04 |
nodejs, reactjs) react to static page - gatsby node api - 개발 기록 4 (0) | 2024.06.03 |