knock-knock-go
knock-knock-go is React a helper to simplify the process of loading asynchronous components by dealing with the logic around when to render the component, an error or a loading message.
How to use it:
// my-knock-knock-go.es6;; const MyLoader = <div>My custom loader</div>;const MyError = <div>My nice error handler</div>;const myKnockKnockGo = ; // my-component.es6;; const MyComponent = <div>do some good stuff</div>;const KnockKnockGoMyComponent = ;
Most times your asynchronously loaded component would need to try to get some data so that it can
actually render anything. You can do it in many ways, here's one with redux
and react-redux
:
// my-other-component.es6;// these are your actions;;; const MyOtherComponent = <div>do some good stuff</div>;const KnockKnockGoMyOtherComponent = ; { // state.myThing would contain isLoading, isReady, error, etc. and all the needed things for your // final component to work return statemyThing;} mapStateToPropsKnockKnockGoMyOtherComponent;
License MIT.
with <3 by UXtemple.