Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
export default class Article extends Component {
// notice that it's an async function
static async getInitialProps () {
// fetch data on the server and parse it to JSON
const res = await
const json = await res.json();
// return data from the server so it can be consumed by our component
// all returned data from this method is added to out React.Component this.props
return {
articleContent: json.content.rendered,
render() {
const { articleContent } = this.props;
return (
<div dangerouslySetInnerHTML={{ __html: articleContent }}/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment