router
router copied to clipboard
Hoverling links with defaultPreload: "intent" causes 2 rerenders of tree, one with missing current route context
Describe the bug
I have defaultPreload: "intent". I have layout route which returns some additional context from beforeLoad. I have some navigation links and when I hover it, in layout route Component I have const { someProp } = Route.useRouteContext(). When I hover any link, my layout route rerenders twice and on first rerender I am getting context without someProp returned from this layout route. I am getting context, including root and upper layout routes context, but not this route context.
It was introduced in 1.32.16
Your Example Website or App
I had small time to check fix for issue with undefined context after redirect and noticed this new issue, I will be able to make reproduction tomorrow, if it will be needed
Steps to Reproduce the Bug or Issue
- Return something from beforeLoad
- call hook Route.useRouteContext() in this route Component
- Hover any other link with defaultPreload: "intent"
Expected behavior
When I hover link, app has not to rerender at all
Screenshots or Videos
No response
Platform
Version: 1.32.16
Additional context
No response
Need a minimal reproduction with the steps required to trigger the behavior you described.
@maksymskuibida any luck with a reproduction? please try it with 1.33.6.
@maksymskuibida any luck with a reproduction? please try it with 1.33.6.
Hello, I'll try. I am sorry, had no time for this. Hopefully I will do it today, if 1.33.6 does not work
@SeanCassiere Only now I had a change to test it. Updating to 1.33.6 fixed this issue. But also it broke throw redirect again.
In my case it happens if I reloads the page with resetting cache (cmd + shift + R) and then do logout, which causes throw redirect in _authorised route beforeLoad. It does not happen on login, where I also do "throw redirect" in login beforeLoad route. I don't know why it happens only on logout.
I will try to create reproduction, but I am busy right now, have a lot of work to do and I don't know when I will have time to do it.
I have just updated to the latest version at it is fixed now. I didn't see in release notes what release could fix it, but it is ok now