Skip to content

PreloadData "ignores" Prefetched data #249

@KalleDK

Description

@KalleDK

I'm nowhere near a good react developer!

The thin I noticed while poking around is that the prefected comments (while hovering a discussion) is ignored afaik.

To replicate (in nextjs)

  • Add a delay on 3+ sec to getComments in get-comments.ts
  • Start the test server
  • Create a discussion and some comments
  • Go to http://localhost:3000/app/discussions
  • Hover the discussion and notice the fetch takes the 3+ seconds (in developer tool)
  • Click the link and notice that it again take 3+ sec to load

To "fix" comment out the queryClient.prefetchInfiniteQuery(getInfiniteCommentsQueryOptions(discussionId)), line in page.tsx in [disussinId]

The server will now not preload the comments. What you now can opserve is

  • When you hover the disussion again notice the 3+ sec
  • Click and the comments are there instant
    OR
  • Click asap on the discussion
  • Notice the spinner is there for the 3+ sec

This behavior is also for the discussion list as in the first page is "slow" as the discussions is preloaded on the server and the page cannot be shown before.

I don't know the correct way of doing this, but I would expect to get to the site quick and then have the spinner while comments / discussions is loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions