question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] useEffect IDisposable

See original GitHub issue

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] )

Issue Analytics

  • State:closed
  • Created a month ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JaggerJocommented, Aug 9, 2023

@huudev this is intentionally so. Could you give a bit more context on why reacts execution strategy is handy/needed?

1reaction
JaggerJocommented, Aug 8, 2023

fixed. (wait for release 1.0.1, should be out in a few minutes)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Returning a callback from useEffect - javascript
React will call this dispose function ONLY when one of the dependencies changes or when it unmounts. to "release" stuff that no longer...
Read more >
[Bug]: Can't unmount Canvas in react useEffect · Issue #8899
Uncaught Error: fabric.js: trying to initialize a canvas that has already been initialized at Canvas.
Read more >
How to Properly Clean Up Effects in useEffect | by Caesar Bell
One reason for this is to avoid memory leaks. When an effect is no longer needed, it's important to properly dispose of any...
Read more >
React - The Missing Parts
To me this is an argument that useEffect + setState is a poor solution for having state change in response to props. It...
Read more >
How to shut down Babylon cleanly on React Route change?
Try using … this.engine.dispose(), I'm using that to clean-up a vue.js ... when the route changes and call what is returned by useEffect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found