Closed huudev closed 1 year ago
What exactly do you mean?
A: printf is not called B: the Dispose method is not called
Dispose
B. I try set breakpoint at Dispose method but it never hit.
fixed. (wait for release 1.0.1, should be out in a few minutes)
fixed. (wait for release 1.0.1, should be out in a few minutes)
Thank you for your enthusiastic support. But i found useEffect's Dispose calling behavior is not the same as useEffect's cleanup calling behavior in Reactjs. In Reactjs the cleanup function call is performed when a new execution in useEffect but useEffect in FuncUI the Dispose function will be kept and executed when the component is destroyed. If this different behavior is your intention then no problem.
I would like to describe more useEffect behavior in reactjs (code reactjs)
Thanks.
@huudev this is intentionally so. Could you give a bit more context on why reacts execution strategy is handy/needed?
@huudev this is intentionally so. Could you give a bit more context on why reacts execution strategy is handy/needed?
One scenario that I often come across is calling http request in useEffect based on a state value and set the response of that request to other state. If Dispose is not called immediately when that value changes, then due to asynchronous reasons the response from previous requests (due execution useEffect from old values) may be returned later and not get the desired result.
Dear developer team. I have a problem with useEffect that when i return IDisposable object it is not called every time count state changes. Please help me. Thanks.
let count = ctx.useState 0 ctx.useEffect ( handler = (fun _ -> printf "m1" { new IDisposable with member this.Dispose(): unit = raise (Exception "a") } ), triggers = [EffectTrigger.AfterChange count] )