最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论