Skip to content

Instantly share code, notes, and snippets.

@AnkurVyas-BTC
Created April 28, 2019 05:04
Show Gist options
  • Save AnkurVyas-BTC/e7f5e96ab75a0125933bf2360e862541 to your computer and use it in GitHub Desktop.
Save AnkurVyas-BTC/e7f5e96ab75a0125933bf2360e862541 to your computer and use it in GitHub Desktop.
React Loadable cool options!
function Loading(props) {
if (props.error) {
return <div>Something went wrong! <button onClick={ props.retry }>Retry</button></div>;
} else if (props.timedOut) {
return <div>Seems like your net is slow... <button onClick={ props.retry }>Retry</button></div>;
} else if (props.pastDelay) {
return <div>Loading...</div>;
} else {
return null;
}
}
Loadable({
loader: () => import('./components/Bar'),
loading: Loading,
delay: 500, // 0.5 seconds
timeout: 150000, // 15 seconds
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment