reactjs - In nextjs, using react's useTransition, next's Link is not working mid transition. Best practice for p

I use NextJS Link component for routing.Also, I use useTransition for server actions.The problem is t

I use NextJS Link component for routing.

Also, I use useTransition for server actions.

The problem is that mid-transition, the Link component does not link.

Furthermore, the transition never ends when the transition action is an API call - because the call is cancelled I assume.

I created a POC for this issue:

What is the best practice for preventing this behavior?

I use NextJS Link component for routing.

Also, I use useTransition for server actions.

The problem is that mid-transition, the Link component does not link.

Furthermore, the transition never ends when the transition action is an API call - because the call is cancelled I assume.

I created a POC for this issue:

https://github/OrenSayag/next-link-mid-transition-issue/tree/main

What is the best practice for preventing this behavior?

Share Improve this question asked Mar 12 at 15:18 Oren SayagOren Sayag 411 silver badge6 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

We have decided to use react-query lib instead of useTransition.

I conclude we were wrong using useTransition for api calls, as the react-query lib provides so much more than just a pending state for this use case.

useTransition is useful for UI intensive tasks, or background UI tasks, but not so much for api calls.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744745346a4591260.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信