galkinrost / react-lifecycle-decorators

Decorators for stateless components
MIT License
13 stars 0 forks source link

Lifecycle decorators Build Status

Lifecycle decorators for stateless components

Installation

npm install -S react-lifecycle-decorators

componentWillMount(props)

const Component = ()=>(
    <div/>
);
export default componentWillMount(props=>props.fetchData())(Component);

shouldComponentUpdate(nextProps, props)

const Component = ()=>(
    <div/>
);
export default shouldComponentUpdate((nextProps, props)=>false)(Component);

componentWillUnmount(props)

const Component = ()=>(
    <div/>
);
export default componentWillUnmount(props=>props.somAction())(Component);

componentWillReceiveProps(nextProps, props)

componentWillUpdate(nextProps, props)

componentDidUpdate(prevProps, props)