Skip to content

Instantly share code, notes, and snippets.

@AnkurVyas-BTC
Created July 25, 2019 12:05
Show Gist options
  • Save AnkurVyas-BTC/4ced5d1a5551ecafeb991b00c663b865 to your computer and use it in GitHub Desktop.
Save AnkurVyas-BTC/4ced5d1a5551ecafeb991b00c663b865 to your computer and use it in GitHub Desktop.
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