Skip to content

Instantly share code, notes, and snippets.

@deniztetik
Created July 8, 2018 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deniztetik/09174255115303c6a33eb6855aa216df to your computer and use it in GitHub Desktop.
Save deniztetik/09174255115303c6a33eb6855aa216df to your computer and use it in GitHub Desktop.
// ./src/Hello.js
import React, { Component } from 'react';
import { withContext } from './index';
class Name extends Component {
async componentDidMount() {
const name = await delay('React', 0);
this.props.setName(name);
}
render() {
return <h1>Hello {this.props.name}!</h1>;
}
}
export default withContext(Name);
// simulate an API Call
const delay = (value, time = 0) =>
new Promise((resolve) =>
setTimeout(() => resolve(value), time)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment