Created
October 11, 2018 08:35
-
-
Save dainelmawer/b5d62f6b572d07f9c29b44306c503428 to your computer and use it in GitHub Desktop.
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, {Component} from 'react'; | |
class Test extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
posts: {} | |
} | |
} | |
componentDidMount() { | |
console.log('Make an API call!'); | |
} | |
componentDidUpdate(prevProps) { | |
if(this.props.featured !== prevProps.featured) { | |
console.log('Looks like props changed'); | |
} | |
} | |
componentWillUnmount() { | |
console.log('Close API call connection'); | |
} | |
render() { | |
const { posts } = this.state; | |
const { author, time, featured } = this.props; | |
const featuredCls = featured ? 'featured' : ''; | |
return( | |
<div className={featuredCls}> | |
<time>{time}</time> | |
<span>{author}</span> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment