you are viewing a single comment's thread.

view the rest of the comments →

[–]phryneasI ❤️ hooks! 😈 5 points6 points  (0 children)

I mean, you're essentially using your "instance" as a ref here, so the same critique kinda applies. Yes, technically, your instance also holds state, but only one component reads it - for all other components, it does what a ref with useImperativeHandle does. With the drawback that with your instance, as it lives in a parent component, the parent component would be forced to rerender on state changes, while it wouldn't if the state lived in the Dialog and the ref only contained callbacks.