Is it possible to pass array (String array) or object from JS to Rust? This code compiles without errors, but does not work.
#[wasm_bindgen]
#[derive(Debug)]
pub struct Input {
array: Vec<String>,
}
#[wasm_bindgen]
pub fn array_length(input: &Input) -> usize {
input.array.len()
}
I also tried serde-wasm-bindgen, but still doesnt work.
WebAssembly does not expect to receive array or object from JS?
You can use JsValue from wasm_bindgen to send arrays between JS and Rust.
And then call it from React like:
Full repo can be found here: https://github.com/eriktoger/rubiks_cube