-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discuss alternative ways for opts.waitFor #114
Comments
Do you have project for which |
@stereobooster in the project I'm working on, it seemed if I didn't set The only thing that I can think of that may have caused it is because the fetch is defined like this (pretty standard really): class C {
async load() {
this.setState(() => ({ isFetching: true, error: null }));
try {
const resp = await fetch('something');
const body = await resp.json();
this.setState(() => ({
response: body
}));
} catch (e) {
console.error(e);
this.setState(() => ({ error: e.message }));
} finally {
this.setState(() => ({ isFetching: false }));
}
}
} As you can see, this.setState(() => ({
response: body
})); In which case the Also, did not know about |
I thought about alternatives to As of why you get |
Async snapshotsI believe there are two good approaches here:
|
Can we use the |
opts.waitFor
is good because you can put something like this in package.json:And hopefully your requests will have loaded after 5s! But when crawling, some pages don't even have a fetch that needs to be waited on.
What about some other options for this?
Option 1: allow it to be a hash of paths:
I used
*
to represent everything else - not sure if there's a better way.Option 2: instead of using package.json, react-snap would have to allow JS to be run. I don't know, could there be a
react-snap.js
file at the root of your project with something like:What do you think about this kind of API change?
Alternatively, do you think that the "waiting" feature is actually a symptom of something else? I've been wondering how crawling is actually meant to work - instead of this, is there a way for the crawler to know that the page is "stable", e.g. not waiting on any fetches, no outstanding renders or state changes to be performed. Just thinking out load.
The text was updated successfully, but these errors were encountered: