router icon indicating copy to clipboard operation
router copied to clipboard

Hoverling links with defaultPreload: "intent" causes 2 rerenders of tree, one with missing current route context

Open maksymskuibida opened this issue 1 year ago • 4 comments

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

  1. Return something from beforeLoad
  2. call hook Route.useRouteContext() in this route Component
  3. 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

maksymskuibida avatar May 18 '24 09:05 maksymskuibida

Need a minimal reproduction with the steps required to trigger the behavior you described.

SeanCassiere avatar May 18 '24 11:05 SeanCassiere

@maksymskuibida any luck with a reproduction? please try it with 1.33.6.

SeanCassiere avatar May 21 '24 03:05 SeanCassiere

@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

maksymskuibida avatar May 21 '24 05:05 maksymskuibida

@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.

maksymskuibida avatar May 23 '24 09:05 maksymskuibida

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

maksymskuibida avatar Jun 03 '24 08:06 maksymskuibida