Giter Club home page Giter Club logo

Comments (5)

MoSattler avatar MoSattler commented on September 27, 2024

Comment by @brophdawg11 in discord.

defer doesnt re-show fallback on revalidations by design (see https://reactrouter.com/en/main/guides/deferred#when-does-the-suspense-fallback-render). When you stay o nthe same page and update search params it's a revalidation since you're already showing the loader data
This is no longer a limitation with the upcoming Single Fetch feature (https://remix.run/docs/en/main/guides/single-fetch) so you will have more control over re-falling back then via

Thank you for taking a look at this, @brophdawg11

This issue is primarily related to defer and not to Suspense. The issue persists regardless of whether Suspense is used or not.

In the case of a search param navigation, the navigation won't execute (and hence not pass ANY data to useLoader) until the last promise in loader is resolved.

Take the case where I pass three values to defer: one is a sync value, the second is a promise that takes 3 seconds, and the third one takes 15 seconds. On the first navigation, this isn't a problem. I can show the sync data immediately, the second promise shortly after, and the slow promise after a while, with a spinner indicating that the data will be shown soon.

However, if I have a search param change, I cannot show any updated data for 15 seconds, not of the faster promise, and not even the new sync one! This is because the navigation will wait for that 15-second promise before it changes the URL and pass any new data to the useLoader. It essentially behaves as if i would not have used defer at all.

from remix.

MoSattler avatar MoSattler commented on September 27, 2024

@brophdawg11 here is a repro illustrating the issue without using Suspense at all: https://stackblitz.com/edit/mosattler-remix-repro-defer-search-params-x4jr7s?file=app%2Froutes%2F_index.tsx

from remix.

brophdawg11 avatar brophdawg11 commented on September 27, 2024

This issue is primarily related to defer and not to Suspense

In the case of a search param navigation, the navigation won't execute (and hence not pass ANY data to useLoader) until the last promise in loader is resolved.

Correct - this is proper behavior and is a design decision made for the handling of defer as outlined in the docs. This will no longer be the case with single fetch so you can adopt that via future.unstable_singleFetch if you really need to bypass this limitation of defer.

from remix.

MoSattler avatar MoSattler commented on September 27, 2024

Alright, thank you for your help on this @brophdawg11

from remix.

andrewbarnesweb avatar andrewbarnesweb commented on September 27, 2024

I don't think is covered at all in the Remix docs anymore? I see a lot of comments regarding this confusion.

Hopefully React Router 7 consolidation will help get it all a bit clearer.

from remix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.