Created
July 25, 2019 12:05
-
-
Save AnkurVyas-BTC/4ced5d1a5551ecafeb991b00c663b865 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 Calculator extends Component { | |
sleep = (milliseconds) => { | |
var start = new Date().getTime(); | |
for (var i = 0; i < 1e7; i++) { | |
if ((new Date().getTime() - start) > milliseconds) { | |
break; | |
} | |
} | |
} | |
timedOutDisplay = (inputVal) => { | |
this.sleep(2000); | |
return `Heavy calculation based on input => ${inputVal}`; | |
} | |
render() { | |
return ( | |
<React.Fragment> | |
{this.timedOutDisplay(this.props.inputVal)} | |
</React.Fragment> | |
); | |
} | |
} | |
export default Calculator; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment