maisano / react-router-transition

painless transitions built for react-router, powered by react-motion
http://maisano.github.io/react-router-transition/
MIT License
2.59k stars 139 forks source link

Lag when transition to another page #97

Closed aibrahim3546 closed 6 years ago

aibrahim3546 commented 6 years ago

when the page changes the transitions become laggy, I found out that it is laggy because of an API call. The transition is getting blocked when calling the API. How do I avoid this problem?

maisano commented 6 years ago

hi @aibrahim3546! this is something that will have a clearer path forward in the future, when async react is a reality. in the meantime, i'm not certain how or when you're making an api call, but deferring it or prefetching it should work well enough. if you're fetching in the componentDidMount of a transitioning component, i would expect there to be a lag. maybe give deferring the call or prefetching it a try.

aibrahim3546 commented 6 years ago

Thank you for the response, So I guess the only way is to delay the API call.

maisano commented 6 years ago

@aibrahim3546 no problem–i might give requestIdleCallback a shot here, if you have it shimmed.