Skip to content

Commit

Permalink
cargo +nightly fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
futursolo committed Apr 22, 2022
1 parent 36ded3f commit c07e60f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
11 changes: 5 additions & 6 deletions packages/yew/src/functional/hooks/use_effect.rs
Expand Up @@ -161,7 +161,7 @@ where
/// # Example
///
/// ```rust
/// use yew::{function_component, html, Html, Properties, use_effect_with_deps};
/// use yew::{function_component, html, use_effect_with_deps, Html, Properties};
/// # use gloo::console::log;
///
/// #[derive(Properties, PartialEq)]
Expand Down Expand Up @@ -189,16 +189,15 @@ where
///
/// ## Only on first render
///
/// Provide a empty tuple `()` as dependencies when you need to do something only on the first render
/// of a component.
/// Provide a empty tuple `()` as dependencies when you need to do something only on the first
/// render of a component.
///
/// ```rust
/// use yew::{function_component, html, Html, use_effect_with_deps};
/// use yew::{function_component, html, use_effect_with_deps, Html};
/// # use gloo::console::log;
///
/// #[function_component]
/// fn HelloWorld() -> Html {
///
/// use_effect_with_deps(
/// move |_| {
/// log!("I got rendered, yay!");
Expand All @@ -217,7 +216,7 @@ where
/// It will only get called when the component is removed from view / gets destroyed.
///
/// ```rust
/// use yew::{function_component, html, Html, use_effect_with_deps};
/// use yew::{function_component, html, use_effect_with_deps, Html};
/// # use gloo::console::log;
///
/// #[function_component]
Expand Down
12 changes: 6 additions & 6 deletions packages/yew/src/functional/hooks/use_force_update.rs
Expand Up @@ -42,10 +42,10 @@ impl UseForceUpdate {
///
/// # Use-case
///
/// Use this hook when wrapping an API that doesn't expose precise subscription events for fetched data.
/// You could then, at some point, invalidate your local cache of the fetched data and trigger a re-render
/// to let the normal render flow of components tell you again which data to fetch, and repopulate the
/// cache accordingly.
/// Use this hook when wrapping an API that doesn't expose precise subscription events for fetched
/// data. You could then, at some point, invalidate your local cache of the fetched data and trigger
/// a re-render to let the normal render flow of components tell you again which data to fetch, and
/// repopulate the cache accordingly.
///
/// A large externally managed cache, such as a app-wide cache for GraphQL data
/// should not rerender every component whenever new data arrives, but only those where a query
Expand All @@ -56,8 +56,8 @@ impl UseForceUpdate {
/// # Example
///
/// This example implements a silly, manually updated display of the current time. The component
/// is re-rendered every time the button is clicked. You should usually use a timeout and `use_state`
/// to automatically trigger a re-render every second without having to use this hook.
/// is re-rendered every time the button is clicked. You should usually use a timeout and
/// `use_state` to automatically trigger a re-render every second without having to use this hook.
///
/// ```rust
/// use yew::prelude::*;
Expand Down
18 changes: 10 additions & 8 deletions packages/yew/src/functional/hooks/use_ref.rs
Expand Up @@ -25,11 +25,12 @@ impl<T: 'static, F: FnOnce() -> T> Hook for UseMutRef<F> {
///
/// # Example
/// ```rust
/// use yew::prelude::*;
/// use web_sys::HtmlInputElement;
/// use std::rc::Rc;
/// use std::cell::RefCell;
/// use std::ops::{Deref, DerefMut};
/// use std::rc::Rc;
///
/// use web_sys::HtmlInputElement;
/// use yew::prelude::*;
///
/// #[function_component(UseRef)]
/// fn ref_hook() -> Html {
Expand Down Expand Up @@ -79,9 +80,10 @@ where
/// # Example
///
/// ```rust
/// use wasm_bindgen::{prelude::Closure, JsCast};
/// use yew::{function_component, html, use_effect_with_deps, use_node_ref, Html};
/// use wasm_bindgen::prelude::Closure;
/// use wasm_bindgen::JsCast;
/// use web_sys::{Event, HtmlElement};
/// use yew::{function_component, html, use_effect_with_deps, use_node_ref, Html};
///
/// #[function_component(UseNodeRef)]
/// pub fn node_ref_hook() -> Html {
Expand Down Expand Up @@ -128,9 +130,9 @@ where
///
/// # Tip
///
/// When conditionally rendering elements you can use `NodeRef` in conjunction with `use_effect_with_deps`
/// to perform actions each time an element is rendered and just before the component where the hook is used in is going to be removed from the
/// DOM.
/// When conditionally rendering elements you can use `NodeRef` in conjunction with
/// `use_effect_with_deps` to perform actions each time an element is rendered and just before the
/// component where the hook is used in is going to be removed from the DOM.
#[hook]
pub fn use_node_ref() -> NodeRef {
(*use_state(NodeRef::default)).clone()
Expand Down

0 comments on commit c07e60f

Please sign in to comment.