Skip to content

Instantly share code, notes, and snippets.

@jamesseanwright
Created July 17, 2019 16:21
Show Gist options
  • Select an option

  • Save jamesseanwright/36a9c2cdfd4c6316eb3f34ae6986180f to your computer and use it in GitHub Desktop.

Select an option

Save jamesseanwright/36a9c2cdfd4c6316eb3f34ae6986180f to your computer and use it in GitHub Desktop.
React lazy resolution state tracking
switch (status) {
case Resolved: {
const Component: T = result;
return Component;
}
case Rejected: {
const error: mixed = result;
throw error;
}
case Pending: {
const thenable: Thenable<T, mixed> = result;
throw thenable;
}
default: {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment