Hi, I'm trying to hide the input and call it from a button. I was looking for a ref alternative and someone said something about using onmount, is this right ?
use dioxus::prelude::*;
use std::rc::Rc;
#[component]
pub fn Settings() -> Element {
let mut path: Signal<String> = use_signal(|| "".to_string());
let mut input_ref: Signal<Option<Rc<MountedData>>> = use_signal(|| None);
let file_select = move |_| {
if let Some(input_data) = input_ref() {
if let Ok(input) = Rc::try_unwrap(input_data) {
// how do I call it ?
}
}
};
rsx! {
div { class: "h-screen w-full bg-green-200 ",
p { "Selected Path: {path}" }
p { class: "bg-red-200", "Settings" }
button { onclick: file_select, "input-file" }
input {
id: "music-path-save",
name: "music-path",
r#type: "file",
hidden: true,
directory: true,
onmounted: move |element| input_ref.set(Some(element.data())),
onchange: move |evt| {
if let Some(file_engine) = evt.files() {
if let Some(dir_path) = file_engine.files().first() {
path.set(dir_path.clone());
}
}
println!("{:?}", path);
},
}
}
}
}