This is unreleased documentation for Yew Next version.
For up-to-date documentation, see the latest version on docs.rs.
yew::functional

Function use_state_eq

Source
pub fn use_state_eq<'hook, T, F>(
    init_fn: F,
) -> impl 'hook + Hook<Output = UseStateHandle<T>>
where T: PartialEq + 'static + 'hook, F: FnOnce() -> T + 'hook,
Expand description

use_state but only re-renders when prev_state != next_state.

This hook requires the state to implement PartialEq.

ยงNote

When used in function components and hooks, this hook is equivalent to:

pub fn use_state_eq<T, F>(init_fn: F) -> UseStateHandle<T>
where
    T: PartialEq + 'static,
    F: FnOnce() -> T,
{
    /* implementation omitted */
}