Created
April 28, 2019 05:04
-
-
Save AnkurVyas-BTC/e7f5e96ab75a0125933bf2360e862541 to your computer and use it in GitHub Desktop.
React Loadable cool options!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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