1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  */
    
  7. 
    
  8. import * as React from 'react';
    
  9. import {useState} from 'react';
    
  10. import {createRoot} from 'react-dom';
    
  11. 
    
  12. function createContainer() {
    
  13.   const container = document.createElement('div');
    
  14. 
    
  15.   ((document.body: any): HTMLBodyElement).appendChild(container);
    
  16. 
    
  17.   return container;
    
  18. }
    
  19. 
    
  20. function StatefulCounter() {
    
  21.   const [count, setCount] = useState(0);
    
  22.   const handleClick = () => setCount(count + 1);
    
  23.   return <button onClick={handleClick}>Count {count}</button>;
    
  24. }
    
  25. 
    
  26. createRoot(createContainer()).render(<StatefulCounter />);