Giter VIP home page Giter VIP logo

Comments (5)

nimaeskandary avatar nimaeskandary commented on August 12, 2024 1

Yep, exactly! Works like a charm

from fetch-hoc.

eliihen avatar eliihen commented on August 12, 2024

Hi,

No, but I'm glad you requested this feature. I don't need this any any of my projects right now, but it is definitely the logical next step forward for fetch-hoc.

I'm thinking the hoc exposes a function like this.props.fetch which forces a new fetch. If you want to try and implement that, you have my blessing and encouragement. I'm on vacation right now, so I don't have a computer with me.

from fetch-hoc.

nimaeskandary avatar nimaeskandary commented on August 12, 2024

Thanks, I gave it a shot, #6

from fetch-hoc.

nimaeskandary avatar nimaeskandary commented on August 12, 2024

Actually we ended up passing the fetchData function as a prop so the child can trigger it's refresh, closed that pr. If I have time I'll try to make another pr with that

from fetch-hoc.

eliihen avatar eliihen commented on August 12, 2024

Hey again,

I managed to get back from vacation into a frenzy of work, so not much time this week either.

Actually we ended up passing the fetchData function as a prop so the child can trigger it's refresh, closed that pr. If I have time I'll try to make another pr with that

Yeah, that was what I had in mind as well. Better to give flexibility on exactly when to fetch to the components that use fetch-hoc. Something like this changeset maybe?

diff --git a/src/index.js b/src/index.js
index f73bfe8..dbc3d7a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -41,6 +41,10 @@ export default (
       this._isMounted = false;
     }
 
+    reFetchData = () => {
+      this.fetchData(this.getUrl());
+    };
+
     fetchData = url => {
       if (!url) return;
 
@@ -116,7 +120,11 @@ export default (
       return false;
     };
 
-    render() {
-      return <Component {...this.props} {...this.state} />;
-    }
+    render = () => (
+      <Component
+        {...this.props}
+        {...this.state}
+        fetch={this.reFetchData}
+      />
+    )
   };

from fetch-hoc.

Related Issues (6)

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.