Last active
September 11, 2018 03:22
-
-
Save thulioph/164630f24455825e7c872dbfd4ffcf01 to your computer and use it in GitHub Desktop.
An example to demonstrate the lifecycle API of Recompose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { lifecycle } from 'recompose'; | |
const MyComponent = ({ data }) => ( | |
<div>{data}</div> | |
); | |
const MyComponentModified = lifecycle({ | |
componentDidMount() { | |
doSomething().then(data => { | |
this.setState({ data }); | |
}) | |
} | |
})(MyComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment