diff --git a/README.md b/README.md index da4fedf..e8857d2 100644 --- a/README.md +++ b/README.md @@ -330,14 +330,14 @@ pub fn web_socket() -> Html { { let history = history.clone(); let ws = ws.clone(); - use_effect_with_deps( + use_effect_with( + ws.message, move |message| { if let Some(message) = &**message { history.push(format!("[recv]: {}", message.clone())); } || () }, - ws.message, ); } diff --git a/crates/yew-hooks/src/hooks/use_effect_update.rs b/crates/yew-hooks/src/hooks/use_effect_update.rs index ada7ea3..069443c 100644 --- a/crates/yew-hooks/src/hooks/use_effect_update.rs +++ b/crates/yew-hooks/src/hooks/use_effect_update.rs @@ -45,7 +45,7 @@ where } /// This hook is similar to [`use_effect_update`] but it accepts dependencies. -/// The signature is exactly the same as the [`use_effect_with_deps`] hook. +/// The signature is exactly the same as the [`use_effect_with`] hook. #[hook] pub fn use_effect_update_with_deps( callback: Callback, diff --git a/crates/yew-hooks/src/hooks/use_latest.rs b/crates/yew-hooks/src/hooks/use_latest.rs index 7b73846..70404b1 100644 --- a/crates/yew-hooks/src/hooks/use_latest.rs +++ b/crates/yew-hooks/src/hooks/use_latest.rs @@ -82,7 +82,7 @@ where /// /// let latest_closure = use_mut_latest(closure); /// -/// use_effect_with_deps(move |_| { +/// use_effect_with((), move |_| { /// *interval.borrow_mut() = Some(Interval::new(1000, move || { /// let latest_closure = latest_closure.current(); /// let closure = &*latest_closure.borrow_mut(); @@ -90,7 +90,7 @@ where /// closure(); /// })); /// move || *interval.borrow_mut() = None -/// }, ()); +/// }); /// /// html! { ///
@@ -135,13 +135,13 @@ where /// /// { /// let state = state.clone(); -/// use_effect_with_deps(move |_| { +/// use_effect_with((), move |_| { /// *interval.borrow_mut() = Some(Interval::new(1000, move || { /// // This will get the latest state and increase it by 1 each time. /// state.set(**latest_state.current() + 1); /// })); /// move || *interval.borrow_mut() = None -/// }, ()); +/// }); /// } /// /// html! { diff --git a/crates/yew-hooks/src/hooks/use_swipe.rs b/crates/yew-hooks/src/hooks/use_swipe.rs index a161e4f..ce7c105 100644 --- a/crates/yew-hooks/src/hooks/use_swipe.rs +++ b/crates/yew-hooks/src/hooks/use_swipe.rs @@ -64,7 +64,7 @@ impl Clone for UseSwipeHandle { /// // You can depend on direction/swiping etc. /// { /// let state = state.clone(); -/// use_effect_with_deps(move |direction| { +/// use_effect_with(state.direction, move |direction| { /// // Do something based on direction. /// match **direction { /// UseSwipeDirection::Left => (), @@ -74,7 +74,7 @@ impl Clone for UseSwipeHandle { /// _ => (), /// } /// || () -/// }, state.direction); +/// }); /// } /// /// html! { diff --git a/crates/yew-hooks/src/hooks/use_websocket.rs b/crates/yew-hooks/src/hooks/use_websocket.rs index ecf74fd..a524829 100644 --- a/crates/yew-hooks/src/hooks/use_websocket.rs +++ b/crates/yew-hooks/src/hooks/use_websocket.rs @@ -125,14 +125,14 @@ impl Clone for UseWebSocketHandle { /// let history = history.clone(); /// let ws = ws.clone(); /// // Receive message by depending on `ws.message`. -/// use_effect_with_deps( +/// use_effect_with( +/// ws.message, /// move |message| { /// if let Some(message) = &**message { /// history.push(format!("[recv]: {}", message.clone())); /// } /// || () /// }, -/// ws.message, /// ); /// } /// diff --git a/examples/yew-app/src/app/hooks/use_effect_update.rs b/examples/yew-app/src/app/hooks/use_effect_update.rs index 21aa641..d2f18e3 100644 --- a/examples/yew-app/src/app/hooks/use_effect_update.rs +++ b/examples/yew-app/src/app/hooks/use_effect_update.rs @@ -21,7 +21,7 @@ pub fn UseEffectUpdate() -> Html { { let count_effect_update = count_effect_update.clone(); let count = count.clone(); - // Count for use_effect_update_with_deps is less than use_effect_with_deps by 1. + // Count for use_effect_update_with_deps is less than use_effect_with by 1. use_effect_update_with_deps( move |_| { count_effect_update.set(*count_effect_update + 1);