1. import * as React from 'react';
    
  2. 
    
  3. import Button from './Button.js';
    
  4. import Form from './Form.js';
    
  5. 
    
  6. import {like, greet} from './actions.js';
    
  7. 
    
  8. import {getServerState} from './ServerState.js';
    
  9. 
    
  10. const h = React.createElement;
    
  11. 
    
  12. export default async function App() {
    
  13.   const res = await fetch('http://localhost:3001/todos');
    
  14.   const todos = await res.json();
    
  15.   return h(
    
  16.     'html',
    
  17.     {
    
  18.       lang: 'en',
    
  19.     },
    
  20.     h(
    
  21.       'head',
    
  22.       null,
    
  23.       h('meta', {
    
  24.         charSet: 'utf-8',
    
  25.       }),
    
  26.       h('meta', {
    
  27.         name: 'viewport',
    
  28.         content: 'width=device-width, initial-scale=1',
    
  29.       }),
    
  30.       h('title', null, 'Flight'),
    
  31.       h('link', {
    
  32.         rel: 'stylesheet',
    
  33.         href: '/src/style.css',
    
  34.         precedence: 'default',
    
  35.       })
    
  36.     ),
    
  37.     h(
    
  38.       'body',
    
  39.       null,
    
  40.       h(
    
  41.         'div',
    
  42.         null,
    
  43.         h('h1', null, getServerState()),
    
  44.         h(
    
  45.           'ul',
    
  46.           null,
    
  47.           todos.map(todo =>
    
  48.             h(
    
  49.               'li',
    
  50.               {
    
  51.                 key: todo.id,
    
  52.               },
    
  53.               todo.text
    
  54.             )
    
  55.           )
    
  56.         ),
    
  57.         h(Form, {
    
  58.           action: greet,
    
  59.         }),
    
  60.         h(
    
  61.           'div',
    
  62.           null,
    
  63.           h(
    
  64.             Button,
    
  65.             {
    
  66.               action: like,
    
  67.             },
    
  68.             'Like'
    
  69.           )
    
  70.         )
    
  71.       )
    
  72.     )
    
  73.   );
    
  74. }