Comments (5)
maybe I just didn't get you right, huh, but what if:
Resolved
,Rejected
,Running
sub-components are maximum dumb and they will be used just to render passed children conditionally, and DON'T PASS ANY DATA to children at all- Move data layer to
Result
(or smth like this) component, which will be used to get fetched (or accumulated) data
from react-async-call.
Not sure that having dumb component for promise lifecycle will be handy, because, for example, if you catch an error you defintely should know what went wrong. So, API for theirs children should be (IMHO) as follows:
Running
- supports only React children, not function. So here we have what you want.Rejected
- supports React children as well as children function with one argument -rejectReason
Resolved
- supports React children as well as children function with one argument -result
. This might be suitable for simple use cases: e.g. if you don't need to collect results between promise resolving and don't want to render anything during promise function run.
In any case, passing function as a child is up to you. If you don't need it, just pass regular react children :)
from react-async-call.
Yep, missed the case with Rejected
component.
But still have some concerns about Result
and Resolved
components: both of them expose fetched data, but Resolved
renders its children depending on Promise state.
So, my thought is just to have only one way to get fetched data.
from react-async-call.
Hm... It seems like I got your point. If Resolved
won't take a children func, it will be still possible to implement my case using composition like this:
<PromiseRenderer.Resolved>
<PromiseRenderer.Result>
{result => ...}
</PromiseRenderer.Result>
</PromiseRenderer.Resolved>
So, agree, ability to pass function to Resolved children should be removed.
from react-async-call.
I am closing this issue, because of changing API is not the best thing after a few month of package usage.
from react-async-call.
Related Issues (20)
- Pass previous result of promise resolving into Rejected component's children function HOT 1
- Possibility to pass children as function to "Running" sub-component HOT 2
- Resolved sub-component should not render it's children during the "running" phase
- Get rid of react strict warnings in React >= 16.1.3 HOT 1
- The automated release is failing 🚨
- react-async-call crashes with react >= 16.5.0 HOT 1
- PromiseRenderer component children function should be one-argumented by config object
- Internals: Use new React Context API instead of old one HOT 1
- Tests Refactoring HOT 1
- Generate API Reference automatically from jsdoc comments HOT 1
- AsyncCall context is not properly sent through AsyncCall.ResultStore HOT 1
- Production/Development builds HOT 1
- Add new PromiseRenderer.Runner component HOT 1
- Add examples of package usage HOT 1
- Rename Pending component to Running
- Clear result when re-run promise-returning function again HOT 1
- add prop `status: 'running' | 'ready' | 'rejected'` to root render prop HOT 3
- Add new property mergeResult into root component. HOT 1
- Add ability to merge results of sequence of promise resolving HOT 1
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 react-async-call.