1. const React = global.React;
    
  2. const ReactDOM = global.ReactDOM;
    
  3. 
    
  4. class Counter extends React.unstable_AsyncComponent {
    
  5.   state = {counter: 0};
    
  6.   onCommit() {
    
  7.     setImmediate(() => {
    
  8.       this.setState(state => ({
    
  9.         counter: state.counter + 1,
    
  10.       }));
    
  11.     });
    
  12.   }
    
  13.   componentDidMount() {
    
  14.     this.onCommit();
    
  15.   }
    
  16.   componentDidUpdate() {
    
  17.     this.onCommit();
    
  18.   }
    
  19.   render() {
    
  20.     return <h1>{this.state.counter}</h1>;
    
  21.   }
    
  22. }
    
  23. 
    
  24. const interval = 200;
    
  25. function block() {
    
  26.   const endTime = performance.now() + interval;
    
  27.   while (performance.now() < endTime) {}
    
  28. }
    
  29. setInterval(block, interval);
    
  30. 
    
  31. // Should render a counter that increments approximately every second (the
    
  32. // expiration time of a low priority update).
    
  33. ReactDOM.render(<Counter />, document.getElementById('root'));
    
  34. block();