pub fn use_drop_with_options<'hook>(
node: NodeRef,
options: UseDropOptions,
) -> impl 'hook + Hook<Output = UseDropHandle>
Expand description
This hook tracks file, link and copy-paste drops.
use_drop
hook with options.
§Example
use yew_hooks::prelude::*;
#[function_component(UseDrop)]
fn drop() -> Html {
let node = use_node_ref();
let state = use_drop_with_options(node.clone(), UseDropOptions {
onfiles: Some(Box::new(move |files, data_transfer| {
// Process files or data_transfer
})),
..Default::default()
});
html! {
<div ref={node}>
<p>
{ "Try to drag & drop or copy & paste something here, e.g. files, links or text" }
</p>
</div>
}
}
§Note
When used in function components and hooks, this hook is equivalent to:
pub fn use_drop_with_options(node: NodeRef, options: UseDropOptions) -> UseDropHandle {
/* implementation omitted */
}