pub fn use_logger<'hook, T>(
name: String,
props: T,
) -> impl 'hook + Hook<Output = ()>where
T: Debug + 'static + 'hook,
Expand description
This hook logs in console as component goes through life-cycles.
§Example
use yew_hooks::prelude::*;
#[function_component(UseLogger)]
fn logger(props: &Props) -> Html {
use_logger("MyComponent".to_string(), props.clone());
let c = use_state(|| 0);
let d = use_state(|| "d".to_string());
use_logger("MyComponent".to_string(), (c.clone(), d.clone()));
html! {
<>
<b>{ " a: " }</b> { props.a }
<b>{ " b: " }</b> { &props.b }
<b>{ " c: " }</b> { *c }
<b>{ " d: " }</b> { &*d }
</>
}
}
#[derive(Debug, Properties, PartialEq, Clone)]
struct Props {
pub a: i32,
pub b: String,
}
§Note
When used in function components and hooks, this hook is equivalent to:
pub fn use_logger<T>(name: String, props: T)
where
T: Debug + 'static,
{
/* implementation omitted */
}