-
-
Save deniztetik/09174255115303c6a33eb6855aa216df 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
// ./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