diff options
author | Ashelyn Rose <git@ashen.earth> | 2025-02-13 23:19:45 -0700 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2025-02-13 23:19:45 -0700 |
commit | b5d6d25912993b91bc1b3ec52c352431398c36d9 (patch) | |
tree | 4aac11f171e826e95ace3c4d63624a2bbd4c3e91 /ui/src/root.tsx | |
parent | 8a0c92f80a797f40bc06f524d37247273351be8e (diff) |
React with ui -> app IPC
Diffstat (limited to 'ui/src/root.tsx')
-rw-r--r-- | ui/src/root.tsx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ui/src/root.tsx b/ui/src/root.tsx new file mode 100644 index 0000000..8db8960 --- /dev/null +++ b/ui/src/root.tsx @@ -0,0 +1,21 @@ +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> + } + </> + ) +} |