UseState

Trait UseState 

Source
pub trait UseState: Sealed {
    // Required method
    fn use_state<T, F>(&mut self, init: F) -> State<T>
       where F: FnOnce() -> T,
             T: Unpin + Send + Sync + 'static;
}

Required Methods§

Source

fn use_state<T, F>(&mut self, init: F) -> State<T>
where F: FnOnce() -> T, T: Unpin + Send + Sync + 'static,

Hooks 提供 use_state 方法,创建响应式状态。

  • init:状态初始化闭包。
  • 返回 State<T>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl UseState for Hooks<'_, '_>