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.  * @flow
    
  8.  */
    
  9. 
    
  10. import * as React from 'react';
    
  11. 
    
  12. export default function App(): React.Node {
    
  13.   return <List />;
    
  14. }
    
  15. 
    
  16. class List extends React.Component {
    
  17.   constructor(props: any) {
    
  18.     super(props);
    
  19.     this.state = {
    
  20.       items: ['one', 'two', 'three'],
    
  21.     };
    
  22.   }
    
  23. 
    
  24.   addItem = () => {
    
  25.     if (this.inputRef && this.inputRef.value) {
    
  26.       this.setState({items: [...this.state.items, this.inputRef.value]});
    
  27.       this.inputRef.value = '';
    
  28.     }
    
  29.   };
    
  30. 
    
  31.   render(): any {
    
  32.     return (
    
  33.       <div>
    
  34.         <input
    
  35.           data-testname="AddItemInput"
    
  36.           value={this.state.text}
    
  37.           onChange={this.onInputChange}
    
  38.           ref={c => (this.inputRef = c)}
    
  39.         />
    
  40.         <button data-testname="AddItemButton" onClick={this.addItem}>
    
  41.           Add Item
    
  42.         </button>
    
  43.         <ul data-testname="List">
    
  44.           {this.state.items.map((label, index) => (
    
  45.             <ListItem key={index} label={label} />
    
  46.           ))}
    
  47.         </ul>
    
  48.       </div>
    
  49.     );
    
  50.   }
    
  51. }
    
  52. 
    
  53. // $FlowFixMe[missing-local-annot]
    
  54. function ListItem({label}) {
    
  55.   return <li data-testname="ListItem">{label}</li>;
    
  56. }