import { useState } from 'react';
import { invoke } from '@tauri-apps/api/core';

export default function Root() {
  const [rustResult, setRustResult] = useState('')

  async function callRust() {
    const result : string = await invoke('greet', {name: 'ashe'})
    setRustResult(result)
  }

  return (
    <>
      <p>Now we have React</p>
      {rustResult
        ? <p>Result from rust: <pre><code>{rustResult}</code></pre></p>
        : <button onClick={callRust}>Call rust</button>
      }
    </>
  )
}
