constloader=<h1>loading eh</h1>constvalidateConditions={props: {magic: true,}state: {canadians: length=>Number.isInteger(length),},}constvalidateOpts={// default satisfied falsesatisfied: false,// validate not just when ready,// but validate every time we render//// true makes it only render when validated onceready: false,// displayed until validdisplayLoading: loader,}
@renderWhen(validateConditions,validateOpts)
@injectPropsClass(['props','state'])classEhextendsReact.Component{staticpropTypes={magic: React.PropTypes.string,}state={canadians: undefined,}componentWillReceiveProps=({magic})=>magic ? this.setState({magic}) : 0render({magic},{canadians}){console.debug({magic, canadians})}}constloadingEh=<Ehmagic={false}/>constvalidEh=<Ehmagic={true}/>
importing
import{injectProps,injectPropsClass,renderWhen,shouldUpdateFor,validateOn,validateSetState,// also exports autobind & shallowEqual// as they are deps anywayautobind,shallowEqual,}from'react-component-decorators'
package size
importinjectPropsfrom'react-component-decorators/lib/injectProps'importinjectPropsClassfrom'react-component-decorators/lib/injectPropsClass'importrenderWhenfrom'react-component-decorators/lib/renderWhen'importvalidateOnfrom'react-component-decorators/lib/validateOn'importvalidateSetStatefrom'react-component-decorators/lib/validateSetState'// also export {shouldUpdateFor, shallowEqual, autobind}importshouldUpdateForfrom'react-component-decorators/lib/shouldUpdateFor'// you can also import from// 'react-component-decorators/src/*'// if you want to load it yourself