Proposal to add something like reacts 'useEffect
See original GitHub issueI thought about adding something like Reacts useEffect to simplify interop with some existing Avalonia Controls (CefGlue for Example)
Browser.create [
Browser.startUrl "duckduckgo.com"
// not sure how to trigger
Browser.useEffect (fun browser -> browser.GoBack())
]
Implementing this feature is not complicated, maybe adding more ‘hook’ for attach und detach could also be helpful for controls that need to be specifically initialised.
Maybe effects should also be located in a new namespace like Avalonia.FuncUI.DSL.Effects
, because they introduce side effects to an otherwise pure DSL.
@uxsoft @AngelMunoz @AngelMunoz opinions ?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (9 by maintainers)
Top Results From Across the Web
A complete Guide to React's proposed new use() hook
React Core team has come up with a new API proposal called the use() hook. This new hook will ensure first-class promise support...
Read more >A complete guide to the useEffect React Hook
A comprehensive guide to the useEffect React Hook, including when and when not to use it, using it with custom Hooks, and much...
Read more >'React Hook useEffect has a missing dependency' warning ...
One answer to a similar question was to put the function outside the component, but that would require me to pass a lot...
Read more >Replacing Component Lifecycles with the useEffect Hook, ...
A walkthrough to help you convert React component lifecycles into Hooks using the useEffect Hook.
Read more >Making Sense of React Hooks
If the React community embraces the Hooks proposal, it will reduce the number of concepts you need to juggle when writing React applications....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Swoorup
useEffect
allows you to do something with the actual instance of the control. I think it should be executed every time (at least by default).It’s just showcasing that you can do a mutation (hence the useEffect name) on an external element/control of the component it could have been a console.log too, it just shows that technically your component can be written in a pure functional way but allowing it to do side effects
I thought global on a more “global” scale like if you could access things that are at namespace level “like” window it would mean it would have been defined earlier in the module. perhaps I’m just not looking it on the right direction
Yeah I think this gives me a better insight on how could they be used, you still need to use your current state to allow it to do what you need.
That could address stateful components coming from other C# libraries indeed. Are there any concerns about F# authored controls? I guess in the end even if you choose F# you still need to to the usual UserControl inheritance and property declaration thing.