I'm new to TS, React, and Tauri, so this question is a bit basic, but I can't seem to figure out how to do this.
System Info:
[⚠] Environment
- OS: NixOS 23.11.0 X64
✔ webkit2gtk-4.0: 2.40.5
✔ rsvg2: 2.56.3
✔ rustc: 1.71.1 (eb26296b5 2023-08-03) (built from a source tarball)
✔ Cargo: 1.71.1
⚠ rustup: not installed!
If you have rust installed some other way, we recommend uninstalling it
then use rustup instead. Visit https://rustup.rs/
⚠ Rust toolchain: couldn't be deteceted!
maybe you don't have rustup installed? if so, Visit https://rustup.rs/
- node: 18.17.1
- npm: 9.6.7
[-] Packages
- tauri [RUST]: 1.4.1
- tauri-build [RUST]: 1.4.0
- wry [RUST]: 0.24.3
- tao [RUST]: 0.16.2
- @tauri-apps/api [NPM]: 1.4.0
- @tauri-apps/cli [NPM]: 1.3.0 (outdated, latest: 1.4.0)
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:5173/
- framework: React
- bundler: Vite
I've created a command like this:
#[tauri::command]
fn get_chart_data() -> [i32; 6] {
[1, 2, 3, 4, 5, 6]
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![get_chart_data])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}