react-lifecycle-decorators

Decorators for stateless components

Usage no npm install needed!

<script type="module">
  import reactLifecycleDecorators from 'https://cdn.skypack.dev/react-lifecycle-decorators';
</script>

README

Lifecycle decorators

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)