Comments (5)
Yep, exactly! Works like a charm
from fetch-hoc.
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.
Thanks, I gave it a shot, #6
from fetch-hoc.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fetch-hoc.