getDerivedStateFromPropsas a callback but without returned state
onGetSnapshotBeforeUpdate(prevProps, props)– any returned value will be passed as
onDidUpdate(prevProps, props, snapshot)
this, you have no direct access to class instance anymore (🎉).
yarn add @hocs/with-lifecycle
;;;const Demo =<h1> isLoading ? 'Loading' : 'Done' </h1>;Demo;
In addition, it can handle a factory function which works like Recompose
As a bonus you can "share" stuff across different lifecycle methods in that factory scope with
let mySharedStuff, just like you did before with
this.mySharedStuff using a class instance.