그나저나, useEffect 에서 Server Actions 호출 할 수 있는 거 나만 몰랐지 또.

https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#useeffect

컴포넌트가 마운트되거나 종속성이 변경될 때 서버 액션을 호출하기 위해 React useEffect 훅을 사용할 수 있습니다. 이는 글로벌 이벤트에 의존하거나 자동으로 트리거되어야 하는 변이에 유용합니다. 예를 들어 앱 바로 가기를 위한 onKeyDown, 무한 스크롤을 위한 교차점 관찰자 후크, 컴포넌트가 마운트되어 뷰 수를 업데이트할 때 등이 있습니다:

라고 합니다.

1

If you have a fediverse account, you can reply to this note from your own instance. Search https://hackers.pub/ap/notes/0196b8ed-d894-7c8e-b636-8c95c91e20c9 on your instance and reply to it.

0