Git Product home page Git Product logo

Comments (5)

slorber avatar slorber commented on May 31, 2024

hi @horyd

I've build this: https://github.com/slorber/react-async-hook

maybe it's what you were looking for?

from react-refetch.

horyd avatar horyd commented on May 31, 2024

Hi @slorber!

Cool package. Does that just take a regular promise as an argument? How is fetchStarwarsHero dependent on id?

If you like check out these two posts I wrote on the topic, the second one in particular might be handy as it is for triggering async behaviour on UI actions.

https://medium.com/@jaryd_34198/seamless-api-requests-with-react-hooks-part-1-7531849d8381
https://medium.com/@jaryd_34198/seamless-api-requests-with-react-hooks-part-2-3ab42ba6ad5c

Happy to chat/collab, let me know :)

from react-refetch.

slorber avatar slorber commented on May 31, 2024

it takes an async function, the 2nd args is the async fn args that will be injected. If they change data is refetched

I'm trying to figure out if my code makes any sense, because suspense probably makes this useless

from react-refetch.

horyd avatar horyd commented on May 31, 2024

I was taking a closer look at Suspense and it kind of applies mostly to the conditional/asynchronous rendering, not so much to the actual logic. I spent a bit of time exploring the concept of triggered async actions in that second article because in Suspense that would look a little odd?

You would need to have the onClick handler set a state variable that then rendered the Suspense component and from within that you made the POST request and handled the response?

from react-refetch.

dpzxsm avatar dpzxsm commented on May 31, 2024

I have open sourced a library very similar to react-retch, named react-decorate-fetch, I would be very happy if someone can help me maintain it together.

from react-refetch.

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.