Skip to content

Commit

Permalink
Update ComposeRef to Leptos 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Almaju committed Jan 19, 2025
1 parent 5393a88 commit dcfd37a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"packages/primitives/leptos/accessible-icon",
"packages/primitives/leptos/arrow",
"packages/primitives/leptos/aspect-ratio",
"packages/primitives/leptos/compose-refs",
"packages/primitives/leptos/direction",
"packages/primitives/leptos/id",
"packages/primitives/leptos/label",
Expand Down
14 changes: 10 additions & 4 deletions packages/primitives/leptos/compose-refs/src/compose_refs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use leptos::{html::ElementDescriptor, Effect, NodeRef};
use leptos::web_sys::Element;
use leptos::{html::ElementType, prelude::*, tachys::html::node_ref::NodeRefContainer};

fn compose_refs<T: ElementDescriptor + Clone + 'static>(refs: Vec<NodeRef<T>>) -> NodeRef<T> {
fn compose_refs<T: ElementType<Output = Element> + Clone + 'static>(
refs: Vec<NodeRef<T>>,
) -> NodeRef<T> {
let composed_ref = NodeRef::new();

Effect::new(move |_| {
Expand All @@ -14,8 +17,11 @@ fn compose_refs<T: ElementDescriptor + Clone + 'static>(refs: Vec<NodeRef<T>>) -
composed_ref
}

pub fn use_composed_refs<T: ElementDescriptor + Clone + 'static>(
pub fn use_composed_refs<T: ElementType<Output = Element> + Clone + 'static>(
refs: Vec<NodeRef<T>>,
) -> NodeRef<T> {
) -> NodeRef<T>
where
T: Clone,
{
compose_refs(refs)
}

0 comments on commit dcfd37a

Please sign in to comment.