Giter Club home page Giter Club logo

Comments (5)

techniq avatar techniq commented on June 21, 2024

Interesting point. I've always used manual and issued the request myself using fetch for POST calls. Since POST calls are more risky (changing data, etc) I've always assumed others would be doing the same.

We could look into supporting a way to trigger an automatic refetch based on other parameters (body, but not necessarily limited to it, for example changing headers, etc).

In your case is it possible to issue the request manually, or does it need to be automatic (and the url fragment is a decent workaround like you found)?

from react-fetch-component.

ncknuna avatar ncknuna commented on June 21, 2024

Yea, I admit that this is a bit of an odd usecase; the API we're calling is doing an analytic query, so it's not actually modifying state, but it may require a lot of input params that are better suited to a body and the query isn't computationally cheap, so it's a POST (I also didn't design the API we're calling, so I don't have much control over the decision :P)

Yea, while options.body is my particular usecase, a more generic solution makes sense to me.

Yea, there are plenty of workarounds. We could use manual, or just keep doing the url fragment thing, so this isn't super urgent. It was mostly just not intuitive to change the body and have it not refetch and not know why without digging into source code.

from react-fetch-component.

techniq avatar techniq commented on June 21, 2024

@ncknuna I added support for this use case with a new deps (aka depenencies) prop.

I use this on new GraphQL component I'm working on where you always POST to the /graphql endpoint with a different body (query/variables). So far it's working well (and plan to open source it once I've settled on the API. Plan is to keep it lightweight (much more so than apollo-client, etc). It's based on react-fetch-component similar to how my react-odata one was.

I need to update the docs to show deps, but take a look at the commit and tests.

from react-fetch-component.

techniq avatar techniq commented on June 21, 2024

@ncknuna Forgot to mention this is in v8.0.0-9 prerelease. Just waiting for Hooks to be released (maybe Feb 4th) to make it 8.0 stable.

from react-fetch-component.

ncknuna avatar ncknuna commented on June 21, 2024

Ah, cool, thanks :D

from react-fetch-component.

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.