Function patternfly_yew::hooks::id::use_suffixed_id
source · pub fn use_suffixed_id<'hook, 'arg0, 'arg1>(
id: &'arg0 AttrValue,
suffix: &'arg1 str
) -> impl 'hook + Hook<Output = AttrValue>where
'arg0: 'hook,
'arg1: 'hook,
Expand description
Use an ID, derived from another one with a suffix.
It can be used in combination with use_id
.
§Example
use yew::prelude::*;
use patternfly_yew::prelude::*;
#[derive(PartialEq, Properties)]
struct Properties {
id: Option<AttrValue>,
}
#[function_component(Example)]
fn component(props: &Properties) -> Html {
let id = use_id(props.id.clone());
let child_id = use_suffixed_id(&id, "-child");
html!({"..."})
}
This value will not change when re-rendering.
§Note
When used in function components and hooks, this hook is equivalent to:
pub fn use_suffixed_id(id: &AttrValue, suffix: &str) -> AttrValue {
/* implementation omitted */
}