Loading.tsx doesn't work when search param change.
Unanswered
Philippine Crocodile posted this in #help-forum
Philippine CrocodileOP
I've /blog route. app/blog/page.tsx file. at the same level have loading.tsx file. app/blog/loading.tsx
in blog/page.tsx file I'm fetching the blog post. this file has async operation. I've search param on /blog route like /blog?category=sport. and based on search param I'm fetching different blog. if there is no search param means fetch all blog. if there is sport search param it means fetch all post for category sport and so on.
when user land on /blog page at that time my loading state is visible. but when I update the search param (there is tab on page to select the category) it is not showing loading state and for few ms it looks like nothing is happening.
so question how can I show loading when search param change?
in blog/page.tsx file I'm fetching the blog post. this file has async operation. I've search param on /blog route like /blog?category=sport. and based on search param I'm fetching different blog. if there is no search param means fetch all blog. if there is sport search param it means fetch all post for category sport and so on.
when user land on /blog page at that time my loading state is visible. but when I update the search param (there is tab on page to select the category) it is not showing loading state and for few ms it looks like nothing is happening.
so question how can I show loading when search param change?
1 Reply
Boerboel
Try using suspense and passing your searchParams value as key and add a fallback loading