GithubHelp home page GithubHelp logo

Comments (12)

ekzhang avatar ekzhang commented on May 13, 2024 1

Unfortunately I don't have a replication at the moment, but the error might have to do with the fact that onMount is called in the constructor? If useSWR is reactively called behind a $: in the dependent fetching scenario, then it would be rerun later in the component lifecycle after the mount has already happened.

from sswr.

ConsoleTVs avatar ConsoleTVs commented on May 13, 2024

A lot of people seem to be getting this as well. Will investigate.

from sswr.

mgarf avatar mgarf commented on May 13, 2024

@ConsoleTVs was this ever fixed? i feel like i'm seeing the error and before i dig deeper wanted to check if maybe its still outstanding issue

from sswr.

ConsoleTVs avatar ConsoleTVs commented on May 13, 2024

It might be. I am in the process of updating the underlying library of both, sswr and vswr. Althought this seems to be related to svelte itself, this library is around 70 LOC specific svelte code. It should not be hard to spot either if you want to help!

Also, could somebody post a replication code on codesandox?

from sswr.

mgarf avatar mgarf commented on May 13, 2024

i might have some time today to dig into this. though im in the early stages of learning svelte, most of my framework knowledge is react, 🤷 doesnt hurt to try

from sswr.

mgarf avatar mgarf commented on May 13, 2024

dropped in

    beforeUpdate(() => {
      console.log('key', key, this.resolveKey(key), options);
      this.use<D, E>(key, onData, onError, {
        loadInitialCache: true,
        ...options,
      })
    });

and moved onData and on Error to be outside of on mount. The good news is that the fetching is now fixed. the problem is we are creating waaay to many subscriptions... so just need to find the underlying refetch for this.use that i can use on the existing subscription

from sswr.

mgarf avatar mgarf commented on May 13, 2024

ok removed my changes and replace onMount with beforeUpdate and added an if condition to check if the subscription has been created. @ekzhang was right the onMount is happening too early

    beforeUpdate(() => {
      // Handlers that will be executed when data changes.

      // Subscribe and use the SWR fetch using the given key.

      if (!unsubscribe)
        unsubscribe = this.use<D, E>(key, onData, onError, {
          loadInitialCache: true,
          ...options,
        }).unsubscribe
    })

I'll create a PR for the above change but I'm not a huge fan of it since it seems hacky. Going to also do some extra testing as well to make sure it doesn't have some weird side effects

from sswr.

eytanProxi avatar eytanProxi commented on May 13, 2024

Still doesn't work ... 😢

from sswr.

ConsoleTVs avatar ConsoleTVs commented on May 13, 2024

@eytanProxi can you manually test this branch? If it works I can merge it: #33

from sswr.

eytanProxi avatar eytanProxi commented on May 13, 2024

@ConsoleTVs : I tried the fix but the bug is still here.
Should we move to TurboQuery ?

from sswr.

ConsoleTVs avatar ConsoleTVs commented on May 13, 2024

I have no idea how to fix that. You can give turbo query a shot, it is basically using Promises. Should be easy to create a small adapter. I am pushing turbo query beyond with vue and specially solidjs as a replacement for this...

from sswr.

smblee avatar smblee commented on May 13, 2024

@ConsoleTVs are you referring to https://github.com/StudioLambda/TurboQuery?

from sswr.

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.