Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created September 25, 2019 15:40
Show Gist options
  • Save sibelius/cc2f9ce9b2b00bdd3acf1ef6203e7278 to your computer and use it in GitHub Desktop.
Save sibelius/cc2f9ce9b2b00bdd3acf1ef6203e7278 to your computer and use it in GitHub Desktop.
createQueryRendererSuspense helper to make it easy add ErrorBoundaryWithRetry and Suspense handling
export const createQueryRendererSuspense = (Component: React.ComponentType<any>) => {
const QueryRendererWrapper = props => {
return (
<ErrorBoundaryWithRetry fallback={(error, retry) => <ErrorView error={error} retry={retry} />}>
<React.Suspense fallback={<LoadingView />}>
<Component {...props} />
</React.Suspense>
</ErrorBoundaryWithRetry>
);
};
return QueryRendererWrapper;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment