useEffect

fun useEffect(vararg deps: Any?, block: SuspendAsyncFn)

执行副作用的hook,通过设置deps依赖,可以在依赖发生变化时触发副作用闭包block的执行。 依赖性会先执行unwrap进行解包装,所以它可以监听 StateRef 这两种包装类。

By setting a deps dependency, you can trigger the execution of an effect closure block when the dependency changes. The dependency will be unwrapped first, so it can listen to both the State and Ref wrappers.