Closed cmeeren closed 5 years ago
Hmm, I've never seen ReactInstance
in the bindings. Not sure what it refers to, but the name is misleading, it seems to indicate an instance of a React class component but looking at Material-UI documentation this doesn't seem to be the case: the anchorEl
receives an actual DOM element. So your solution seems to be fine.
Thanks! Are you saying that this is the best way to do it? There's no better way that doesn't require generating random IDs exclusively for this use?
Note: ReactInstance
can be a Component<_,_>
too, not just a plain DOM element:
Not sure if it's the "best" way to do it, but I cannot think of an alternative atm as I haven't tested the library :) I tend to trust more the official documentation than the bindings, because they may have errors or be outdate (in fact, I'm thinking of removing the Fable.Import.React file from the library) and the docs for material-ui anchorEl
only talk about a DOM element.
You can add the ID to your model if you don't to generate a random one in the view function.
Thanks. Random IDs it is, then. :)
I am using a property that needs a
ReactInstance
. My code, simplified, is (using Material-UI):where
MaterialProp.AnchorEl: ReactInstance -> MaterialProp
.I see that
ReactInstance
is an alias forU2<Component<obj, obj>, Element>
. But how can I get either aComponent
orElement
for the type I need? I currently generate a random GUID-based ID in the component constructor and usewhich works, but doesn't seem very "react-ish".