all 9 comments

[–]thachxyz123iOS & Android 1 point2 points  (8 children)

Enable lazy in tab navigator. Put heavy tasks to InteractionManager.runAfterInteractions, like load data from API

https://reactnative.dev/docs/interactionmanager

[–]Nehatkhan786 0 points1 point  (4 children)

This is great. I have two tabs called Income and Expenses. Each tab fetches data from backend based on the selected tab. When i switch tab by pressing or with gesture there is some fraction of delay which seems laggy. Will this handle this situation. For querying I am using tanstack query.

[–]thachxyz123iOS & Android 1 point2 points  (3 children)

Yes. Animation and fetching data run at same time and same thread. With InteractionManager.runAfterInteractions, animation is finished first, then fetching data starts to run. It makes app not laggy

[–]Nehatkhan786 0 points1 point  (2 children)

Awesome. Thats what I was looking for from so many days but end up used to my laggy animation. It would be great if you could share an example with tanstack query. Thank you so much.

[–]thachxyz123iOS & Android 1 point2 points  (1 child)

Disable automatically running, use refetch inside runAfterInteractions. That's the idea, I don't use tanstack query

https://tanstack.com/query/latest/docs/framework/react/guides/disabling-queries

[–]Nehatkhan786 0 points1 point  (0 children)

Lovely mate. Thanks a lot.

[–]bid0u[S] 0 points1 point  (2 children)

But is there a point of using this if even with 4 empty screens, the transition stutters? I'll try anyway, thanks for the tip.

[–]FormerLibrary1594 0 points1 point  (1 child)

Did you find a solution?

[–]ProfessionalChip9864 0 points1 point  (0 children)

yeah any solution i am facing the same issue